Title basically explains it all, but I’ll explain it again, I’ve created a folder with values, I want to check if multiple values are true, cause there’s only 1 value allowed to be true for my other script to function properly
this is what I have so far:
local remote = game.ReplicatedStorage.RemoteEventCheck
remote.OnServerEvent:Connect(function(plr)
while wait() do
local char = game.Workspace:FindFirstChild(plr.Name)
local inv = game.ReplicatedStorage.Inventories:FindFirstChild(plr.Name)
local childr = inv:GetChildren()
for i, v in pairs(childr) do
if v.Value == true then
end
end
end
end)
Yes, but what I want is basically to see if multiple values are true, cause right now it only checks if it’s true, not if multiple values are true, it doesn’t check it individually.
local remote = game.ReplicatedStorage.RemoteEventCheck
remote.OnServerEvent:Connect(function(plr)
local char = plr.Character
local inv = game.ReplicatedStorage.Inventories:FindFirstChild(plr.Name)
for i, v in pairs(inv:GetChildren()) do
if v.Value == true then
print(v)
end
end
end)
It loops through every children and your if statement will check if each of the values are true, so if one of the values is not true it will not run the code below your if statement for that individual object, so you can add an else statement to do whatever you want to do if the value isn’t true. Your code I believe is already correct.
I get that, but what I actually want to do is whenever there is more than 1 value, the other one will be set to false and if I write a line of code there, it would be for both values, kind of hard to explain.
local remote = game.ReplicatedStorage.RemoteEventCheck
local truevalue = 0
local falsevalue = 0
remote.OnServerEvent:Connect(function(plr)
while wait() do
local char = game.Workspace:FindFirstChild(plr.Name)
local inv = game.ReplicatedStorage.Inventories:FindFirstChild(plr.Name)
local childr = inv:GetChildren()
for i, v in pairs(childr) do
if v.Value == true then
truevalue += 1
else
falsevalue +=1
end
print(truevalue .." "..falsevalue )
end
end
end)
local StuffThatShouldBeTrue = {"Hi","Hello","Bye"}
for i,v in pairs(Something:GetChildren()) do
if v.Value == true and table.find(StuffThatShouldBeTrue,v.Name) then
for x,y in pairs(StuffThatShouldBeTrue) do
if y == v.Name then
table.remove(StuffThatShouldBeTrue,x)
end
end
if #StuffThatShouldBeTrue == 0 then
-- every single value was true
end
end
end
I am not sure if this is 100% best way to do this, I am also not a professional so if anyone thinks this code is horrible just simply let me know, I am just trying to help but I think this should do it.