I want to write a script that sets every bool value in the Players.SleepBrigadeHolder (or other player name) to false without listing every single value in it, on death of that player’s character. I’m not sure where to start, like where to put this script anyways. Help?
You can use an in pair loop to go through all the booleans and set those to false. You can also create a function where you pass the player’s object into the parameter for convenience.
I’ve read through the roblox documentation, and I am confused on how the player boolvalues would fit into (example code from documentation) this example:
local myDictionary = {
["Blue Player"] = "Ana",
["Gold Player"] = "Binh",
["Red Player"] = "Cate",
}
for key, value in pairs(myDictionary) do
print(key .. " is " .. value)
end
What am I supposed to be putting in the myDictionary table for the boolvalues? Do I list every single boolvalue possible?
You can store arrays inside a key in order to have two values in one. You could also have a dictionary stored in a key if you want it to be that way. It’s not necessary to list every boolvalue, but you can use a loop that will do the same procedure for all players.
Actually let me rephrase my question, I’m trying to do a loop that checks everything in the Player’s LocalPlayer to see if it’s a boolvalue or not. I’m not sure if the example or in pair loop is in this ballpark
You can do something like:
local Players = game:GetService("Players")
--onEvent:Connect(function()
for i, v in pairs(Players:GetChildren()) do
v.Bool.Value = false
end
end)
and put it in ServerScriptStorage. You can also replace the Players:GetChildren() to Players.SleepBrigadeHolder:GetChildren()
for _,v in game:GetService("Players"):GetChildren() do
if v:IsA("BoolValue") then
v.Enabled = false
end
end
Just do a for loop and check their bool so like:
for i, v in pairs(Players:GetChildren()) do
for i, v in pairs(v:GetChildren()) do
if v:IsA("BoolValue") then
print("Is a bool")
end
end
end
And if you don’t want a disgusting amount of for loops then just set some variables.
local myDictionary = {
["Blue Player"] = false,
["Gold Player"] = false,
["Red Player"] = false,
}
for key, value in myDictionary do
game:GetService("Players"):FindFirstChild(key,true).Value = value
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.