Hi all, I’m currently working on a fire generation system, and in the process of generating fires, it needs to change a bool value to enable some other things to happen, however the value isn’t changing, and it appears the script is almost skipping the line that changes it.
Code:
local isActive = script.IsActive.Value
-- plus some other stuff that isn't really relevant and would just take upp
-- more space!!
while true do
wait(ImportantNumberTingAMaBob)
print("checking players")
firePlayers = #fireTeam:GetPlayers()
if isActive == false and firePlayers >= requiredFiries then
print("requirements met")
isActive = true
-- some more stuff
end
end
Everything is working aside from the boolean changing. This is the parenting used.
I can confirm the rest of the script is running, as the multiple prints are functioning, plus the fires generating, however some other important things also aren’t working due to this bool not changing.
Any ideas?
In this case, you have written a value to the variable (local isActive = script.IsActive.Value) and are no longer checking it. Do this:
local isActive = script.IsActive
-- plus some other stuff that isn't really relevant and would just take upp
-- more space!!
while true do
wait(ImportantNumberTingAMaBob)
print("checking players")
firePlayers = #fireTeam:GetPlayers()
if isActive.Value == false and firePlayers >= requiredFiries then
print("requirements met")
isActive.Value = true
-- some more stuff
end
end
A separate function changes it back, however said function only runs when isActive and some other criteria are met. As for the print check, it’s coming back as true but instantly switches to false. I can’t find any scripts changing it, as this is the only function that should be changing it’s value
while true do
wait(1)
if isActive == true then
timer = timer + 1
print(timer)
if timer >= timerThreshold then
print("timeout")
fireEvent:Fire("TIMEOUT")
print("fired")
script.Parent.IsActive.Value = false
print("val changed")
end
end
end
timerThreshold is equal to 60, so it should only change after a minute