What i want is that when i click a gui button (for example), its check in my leaderstats and look in all the values if they = 1 and set them to 0 if they = 1. Its like a "GetChildrenWhichEquals". Im not really good to explain but i think you understands.
✓ ANSWER ACCEPTED
How to make a GetChildrenWhichEquals?
1 answer
✓ Accepted answer
You can write a function for it:
GetChildrenWhichEquals returns a table with all the value objects that equal number
function GetChildrenWhichEquals(parent, number)
local childrenWithValue = {}
--go through all the parents children:
for _, child in pairs(parent:GetChildren()) do
-- if child is a value object then
if child.ClassName:sub(-5) == "Value" then
--check if the child's value equals value specified
if child.Value == number then
table.insert(childrenWithValue, number)
end
end
end
return childrenWithValue
end
local leaderstats = game.Players.LocalPlayer.leaderstats
local children = GetChildrenWhichEquals(leaderstats, 2)
5 comments
0
has to strictly equal the number though. you might have some issues with floating points
0
what is the name of the values that equal number if i want to change them?
0
also what name do i need to change? number?
0
nvermind im sstupid sometime
0
i gave example
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
More like a FindValueWhichEquals