Trying to make a simple tool giver

I’m trying to make a tool giver. I looked at this thread Tool Giver not working but it still doesn’t work
The script:

local tool = game.ServerStorage.Tool

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	local give = tool:Clone()
	give.Parent = player.Backpack
end)
7 Likes

Have you tried instead moving the tool into replicated storage, and making the code a bit more simple like this.
Local tool = game.ReplicatedStorage.Tool

script.Parent.ClickDetector.Mouseclick:Connect(function(player)
tool:Clone().Parent = player:WaitForChild[“Backpack”]

No, it doesn’t for some reason.

Did you try doing the function without the (player) and just function()?

If you mean this

script.Parent.ClickDetector.Mouseclick:Connect(function()
	tool:Clone().Parent = game.Players.Localplayer:WaitForChild('Backpack')
end)

Then no.

local tool = game.ServerStorage:WaitForChild("Tool")

script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player then
	local give = tool:Clone()
	give.Parent = player.Backpack
end
end)

Make sure it is a server script, or it will not work.

14 Likes

Try this:

local gear = game:GetService("ServerStorage").Tool

script.Parent.MouseButton1Click:Connect(function(click)
local player = game:GetService("Players"):GetPlayerFromCharacter(click.Parent)
if player then
local give = gear:Clone()
give.Parent = player.Backpack
end
end)

Sorry for the indentation. I wrote this on mobile.

If that doesnt work, try put “click” instead of click.Parent as the parameters.

1 Like

Had to change the

local tool = game.ServerStorage:WaitForChild("Tool")
to
local tool = game.ServerStorage.Tool

But thanks!