The two giveTool sections copies the tool from the ShopItems folder in ReplicatedStorage and puts it in the players Backpack and in their StarterGear so they have it after death. If you did not add a IntValue inside the tool in ReplicatedStorage and rename it to Price this will cause an error in the first line. This section starts by checking to see if the player has enough Money to buy the tool. This part checks to see if the player already has the tool in their hand or in their backpack. This section of code above is the final part in getting the tool to the player. RemoteEvent.OnServerEvent:Connect(buyTool) Local giveTool = ReplicatedStorage.ShopItems:Clone() If player.Backpack:FindFirstChild(tool.Name) then If player.Character:FindFirstChild(tool.Name) then Sometimes you may get an extra ( ) inside Connect ( ) like this buy_1.MouseButton1Click:Connect(buyTool1 ( ) ). This is the sections of code from the LocalScript that deal with buying tools. Start by checking the output to see if you are getting any error messages. Use the output to identify the error and post it in chat Make sure you add a remote event toReplicatedStorage and rename it to BuyTool. The remote event was not added or named incorrectly Make sure your buy buttons are name buy1, buy2, and bu圓. Make sure your close button is named closeButton. The gui objects inside the frame must match the names used in the script. If you did not name the part the player goes to when the frame closes closePart then change the name in the explorer menu. If you did not name the part that the player steps on openPart then change the name in the explorer menu. Click these messages to open the script at the point of error. In the output window error messages will be highlighted in red. Check the output section by clicking the view tab at the top and then selecting the output button. There is an error somewhere in the script. Local tool = ReplicatedStorage.ShopItemsĬloseButton.MouseButton1Click:Connect(closeMenu)īuy_1.MouseButton1Click:Connect(buyTool1)īuy_2.MouseButton1Click:Connect(buyTool2)īuy_3.MouseButton1Click:Connect(buyTool3) Local player = game.Players:FindFirstChild() Local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool') Local ReplicatedStorage = game:GetService('ReplicatedStorage')
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |