I have this Local Script:
for i,v in pairs(player.PlayerGui.Quests.Background:GetChildren()) do if v:FindFirstChild("Active") and not v.Active then --Do some juicy stuff elseif v:FindFirstChild("Active") and v.Active then print("Still prints true -.-") end end
Active
is a boolean value
I have in almost every child in the folder I'm looping through.
What I want to do is for the script to "Do some juicy stuff" when that value is false (Which it is), but instead it keeps printing true even when the value is false.
I had the first value in the list checked and it was false, I ran the script and it still printed that it was true.
This is getting me so annoyed I'm already at this for 1 hour.
Any help is really appreciated!
Thanks!
Insert a
boolValue
insideWorkspace.script
Check in the
boolValue
and rename it toValueChecker
local BooleanValue = script:FindFirstChild("ValueChecker") if not BooleanValue then print("Not") else print ("Yes") end
Notice the output when you check
and uncheck
the ValueChecker
[First Time] - Yes
[Second Time] - Yes
You are not actually looking for the Value
of the BooleanValue
here. When you simply do if not BooleanValue then
that is never true because BooleanValue does exist in the Workspace
because you are simply checking whether the Value
exist in the Workspace
or not. If the ValueChecker
was not present, then the script would print not
Since you are looking for the value
of the BooleanValue
, change it to if not BooleanValue.Value then
Test the code now and see the difference
local BooleanValue = script:FindFirstChild("ValueChecker") if not BooleanValue.Value then print("Not") else print ("Yes") end
for i,v in pairs(player.PlayerGui.Quests.Background:GetChildren()) do if v:FindFirstChild("Active") and not v.Active.Value then --Do some juicy stuff elseif v:FindFirstChild("Active") and v.Active.Value then print("Still prints true -.-") end end
Learn More