Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a tool giver that does not give the tool to players if they already have it?

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)

4 comments

0

Where is your code for the giver?

0

Oh, I have put it inside already

0

Is Toolname a variable that is already defined?

0

Yes

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.