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
6 years ago

nothing in output look line5 it doesnt work

01while true do
02    wait(120)
03    game.Players.PlayerAdded:Connect(function(plr)
04        plr.Chatted:Connect(function(msg)
05    if game.Workspace.player.tool.Equipped == true and msg == "Rick give me all ur money" then
06    game.Workspace.Door1.Transparency = 1
07    game.Workspace.Door1.CanCollide = false
08    wait (60)
09    game.Workspace.Door1.Transparency = 0
10    game.Workspace.Door1.CanCollide = true
11end
12end)
13end)
14end
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 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 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.

01game.Players.PlayerAdded:Connect(function(plr)
02    plr.Chatted:Connect(function(msg)
03        if plr.Character:FindFirstChild("tool") and msg == "Rick give me all ur money" then
04            game.Workspace.Door1.Transparency = 1
05            game.Workspace.Door1.CanCollide = false
06            wait(60)
07            game.Workspace.Door1.Transparency = 0
08            game.Workspace.Door1.CanCollide = true
09        end
10    end)
11end)
Ad

Answer this question