How would someone go through a table of characters and toggle a value in each one?

This is just a general scripting question to which I need the answer to be an example script.

None of my scripts currently need it, I am just preparing.

1 Like

I’d simply go with something like this.

Script : ServerScriptService

Local players = game:GetService("Players")

for _, player in pairs(players:GetPlayers()) do
    local value = player.Character:FindFirstChild("Your_Value")

    if value then
        value.Value = not value.Value
    end
end
2 Likes

Question: why is i replaced with an underscore?

1 Like

Because i is not used, whenever you use an underscore it means its an unused variable.

1 Like

Ah, I see now. Thank you!!! (Keys)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.