Tool Giver not working

Hi
I have been creating a tycoon lately and one thing a tycoon with pvp must have is weapons
but everytime I try and make a tool giver nothing works.
I make a part I insert a click detector and insert a script into the part.
and I put a sword into ReplicatedStorage

The Script:

local tool = game.ReplicatedStorage.Card
local giver = script.Parent
local canGive = false

local function GiveTool(player)
if canGive == false then
canGive = true
local clone = tool:Clone()
clone.Parent = player.Backpack
wait(1)
canGive = false
end
end

giver.ClickDetector.MouseClick:Connect(function(player)
GiveTool(player)
end)

I would really appreciate if anyone could help me out here

3 Likes

This would go in uh #help-and-feedback:scripting-support

I recommend putting the item in ServerStorage and defining it from there.

I use this script when using a click detector.

local tool = game.ServerStorage["ItemName"]
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	local give = tool:Clone()
	give.Parent = player.Backpack
end)```

Hope this helps!
3 Likes