Tool Giving GUI not working

Hello everyone, as you can see by the title my GUI Tool Giving thingy isn’t working. It works as the player will receive the tool. But when you actually use it the tool itself doesn’t work.

I’ve tried different tools to make sure it wasn’t just the tool I was using and none of them worked.
I’ve also tried to find solutions to this but can’t seem to find any.

Here is my code:

local tool = game.ReplicatedStorage.Sword
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	tool:Clone().Parent = player.Backpack
end)

Anything would help, thank you.

From the line game.Players.LocalPlayer I can tell that you’re using a local script but you need to use a server script to give some player a tool.

To do that you need to use a Remote Event/Function to call the server script once a player clicks the button.

You can check remote functions/events here - Custom Events and Callbacks | Documentation - Roblox Creator Hub

1 Like

Thank you so much, that worked!

1 Like