So i am trying to make a gui button that gives player a tool. Script I am using is below. Roblox doesnt give me any script error. But the button doesnt give the tool to the backpack for some reason. Can someone tell me what am I doing wrong? Thanks
local debounce = true script.Parent.mec.MouseButton1Down:Connect(function(player) if debounce == true then debounce = false local tool = game.ReplicatedStorage.ClassicSword:Clone() tool.Parent = player.Backpack wait (2) debounce = true end end)
Buttons and all the Ui things are client sided, therefore they require local scripts. But for things that should have an effect on all players (serversided) like giving someone a tool you need scripts. So you have to combine a local script that handles the MouseClick with a script that handles the tool giving. To do that you can use RemoteEvents : https://developer.roblox.com/en-us/api-reference/class/RemoteEvent . Make sure to read that article. But basically Remote events are used for Client>Server and Server>Client comunication. I hope I could help you out. If you have questions please write a comment to this answer so I will see it. Have a nice day, esepek.