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

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

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

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

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