You could also copy paste the function xinfinite times and it would probably work.
spawn(function(Number)
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
if _G.NumberVar == 3 then
print("Number 3")
else
print("Not Number 3")
--reset
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end)
It looks like you’re trying to poll the function to detect when the value is what you want. Don’t do that.
What you can do is either use BindeableEvents or a custom wrapper like
local Value: number = 1
local function OnValueChange(): ()
if Value == 3 then
...
end
end
local function ChangeValue(NewValue: number): ()
Value = NewValue
OnValueChange()
end
ChangeValue(2)
Also don’t use _G, it opens up race conditions and doesn’t get typed. ModuleScripts are the way to go with sharing variables.