How can I make a tool giver that detects the player's backpack and only give a tool to the player only if the player does not have the tool? If the player have the tool, the tool giver will not give the player the tool.
Here's the code that gives the player the tool multiple times:
function boop(Player) if not Player.Backpack:FindFirstChild(Gun) then local Tool = game.Lighting[Gun]:clone() Tool.Parent = Player.Backpack end end script.Parent.ClickDetector.MouseClick:Connect(boop)
You also need to check if they are currently holding the tool, in which case it will be in their character model
function boop(Player) local ToolName = Tool.Name if not Player.Backpack:FindFirstChild(ToolName) then if not Player.Character:FindFirstChild(ToolName) then --Code for cloning the tool would go here end end end
I haven't tested this code, but it should work in theory