Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i verify if a tool has been equipped?

Asked by
tacotown2 119
5 years ago

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
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 ieatandisbaconhair 77 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)

Ad

Answer this question