The part is supposted to give a tool on mouse click, it must do it only once.
I have tried watching Youtube tutorials, doesnt help
-- function to give tool
local function giveTool(player)
-- check if player already has the tool
if player.Backpack:FindFirstChild("Crowbar") == nil then
-- create the tool and add it to the player's backpack
local Crowbar = Instance.new("Tool")
Crowbar.Name = "ToolName"
Crowbar.Parent = player.Backpack
end
end
-- connect click event to giveTool function
ClickDetector.MouseClick:Connect(function(player)
giveTool(player)
end)
The part is supposted to give you a tool once on click.
-- function to give tool
local function giveTool(player)
-- check if player already has the tool
if not player.Backpack:FindFirstChild("Crowbar") then --I like using "not" since it's easier
local Crowbar = Instance.new("Tool")
Crowbar.Name = "Crowbar" --You did not define the name you wanted so you would not get the"Crowbar" item even if the script worked
Crowbar.Parent = player.Backpack
end
end
-- connect click event to giveTool function
script.Parent.ClickDetector.MouseClick:Connect(function(player) --You did not define "ClickDetector" so i just replaced it with the location of your actual click detector
giveTool(player)
end)
I sadly can not test it right now but if it’s working please mark my post as an solution, if it’s not working please tell me the error that you received
-- function to give tool
local function giveTool(player)
-- check if player already has the tool
if not player.Backpack:FindFirstChild("SledgeHammer") then --I like using "not" since it's easier
local SledgeHammer= game.Lighting:FindFirstChild("SledgeHammer"):Clone()
SledgeHammer.Parent = player.Backpack
end
end
-- connect click event to giveTool function
script.Parent.ClickDetector.MouseClick:Connect(function(player) --You did not define "ClickDetector" so i just replaced it with the location of your actual click detector
giveTool(player)
end)