How to check if player has tool?

I’m trying to check if a player has a certain tool that is given to them in game.
Basically, player clicks part > player gets tool > player needs said tool to get past checkpoint

I’m checking for tool with
player.Backpack:FindFirstChild("ToolName")
but it doesn’t work.

I’ve noticed that if I give tool to player with dev console tool:Clone().Parent = player.Backpack, when I check for tool it returns true. But when I give in game

    script.Parent.ClickDetector.MouseClick:Connect(function(player)
    	tool:Clone().Parent = player.Backpack
    end

the check returns nil. I’ve tried giving the player the tool using both server and client scripts, though in client I couldn’t even get the tool in the player’s backpack. The check is in server.

How would I make this work?

17 Likes

If the player is holding the tool out, the tool is parented out of their backpack into their character. By any chance, when you ran your check, was the character holding the tool?

2 Likes

@colbert2677 is correct, when you have a tool equipped it is a child of the character. Try this:

local Tool = player.Backpack:FindFirstChild("ToolName")  or player.Character:FindFirstChild("ToolName")
if Tool then
-- allow past checkpoint
end

Hope this helped!

34 Likes

oh me oh my its goes into the character that is truly wild

11 Likes