How do I make a tool limit?

Im trying to make it so the player is only permited to spawn 1 tool, and when they die they can get it again. This script isnt working any fixes?

local player = game.Players.LocalPlayer

local valueBought = player.BoughtItem

local tool = game.Lighting:FindFirstChild(“ClassicSword”)

script.Parent.MouseButton1Click:Connect(function()
if valueBought.Value == false then
local a = tool:Clone()
a.Parent = player.Backpack
valueBought.Value = true
end
end)

game:GetService(‘Players’).PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild(“Humanoid”).Died:Connect(function()
valueBought.Value = false
end)
end)
end)

1 Like

Hey! Welcome to the cookie forums.
To make the post easier to read for our coding friends, format your code with a code block. (`code`)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.