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

How can you make a tool being equipped change a value?

Asked by 7 years ago
local player = game.Players.LocalPlayer
local character = player.Character

local Allow
for _, child in pairs(character:GetChildren()) do
    if child:IsA("Tool") then
        Allow = false

    else
        Allow = true

    end
end

I'm trying to detect if the player has any tools equipped. Doing so would change Allow to false, disabling them from doing things that need Allow to be true. However, this part of my script isn't functioning.

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
7 years ago

You set "Allow" to false every time it sees an object that isn't a tool. Make it so that if it is a tool, set it to true, and if not, do nothing. If there is at least 1 tool, it will be true.

local player = game.Players.LocalPlayer
local character = player.Character

local Allow = false
for _, child in pairs(character:GetChildren()) do
    if child:IsA("Tool") then
        Allow = true
    end
end
Ad

Answer this question