Hey, so pretty much im trying to see if a player has a designated tool or not. It doesnt give me any errors in console. Code:
clickDetector.MouseClick:Connect(function()
local Tool = plr.Backpack:FindFirstChild("LadderTool") or plr.Character:FindFirstChild("LadderTool")
if Tool then
if equipped then
ladderEvent:FireServer()
script.Parent:Destroy()
end
elseif Tool == nil then
print("No tool found")
end
end)
When a tool is equipped the tool will be parented to the player character/model.
and when it is unequipped it will be parented to the backpack.
So, there is no need for the equipped Boolean.
If you are using a server script you cant really define the player outside the function, you gotta do it in the click function.
As the first variable in the function is the player who clicked.
Lastly, when a player has a tool equipped it does not allow them to activate click detectors. So best case right now is to find the tool in their backpack instead.
local clickDetector = script.Parent:WaitForChild("ClickDetector")
clickDetector.MouseClick:Connect(function(player) --Get the player who clicked!
--Find the tool!!!!!
local findTool = player.Backpack:FindFirstChild("LadderTool")
--Check if tool is there!
if findTool then
print("found!")
ladderEvent:FireServer()
script.Parent:Destroy()
else
print("tool not found!")
end
end)