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

how do i verify if a tool has been equipped?

nothing in output look line5 it doesnt work

while true do
	wait(120)
	game.Players.PlayerAdded:Connect(function(plr)
        plr.Chatted:Connect(function(msg)
	if game.Workspace.player.tool.Equipped == true and msg == "Rick give me all ur money" then
    game.Workspace.Door1.Transparency = 1
    game.Workspace.Door1.CanCollide = false
    wait (60)
    game.Workspace.Door1.Transparency = 0
    game.Workspace.Door1.CanCollide = true
end
end)
end)
end

1 comment

0

tool.Equipped isnt a thing, thats an event. add an boolvalue to the tool and call it equipped and instead of if game.Workspace.player.tool.Equipped == true do this instead: if game.Workspace.player.tool.Equipped.Value == true

1 answer

✓ Accepted answer

The "while true do" is completely unnecessary as when you connect the function to an event (plr.Chatted) it will run every time the event fires without the need for a loop. Also, why is there a 120 second wait() before the function?

Equipped is not a property of the tool instance so instead we can just check for the tool inside of the player's character and game.Workspace.Player just doesn't exist and should be replaced with plr.Character if you are trying to find the character.

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
	    if plr.Character:FindFirstChild("tool") and msg == "Rick give me all ur money" then
		    game.Workspace.Door1.Transparency = 1
		    game.Workspace.Door1.CanCollide = false
		    wait(60)
		    game.Workspace.Door1.Transparency = 0
		    game.Workspace.Door1.CanCollide = true
		end
	end)
end)

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