This code should work, but it says in the output that intermission is nil. why does it say that and how can I fix it?

function start()
for intermission=30,0,-1 do
	UpdateEvent:FireAllClients(intermission)
	wait(1)
end
end
function gameLooping()
	repeat	
intermission = intermission - 1--aparently nil
print(intermission)
wait(1)
UpdateEvent:FireAllClients(intermission)
	until intermission = -30 --example
	end 

edit: if i define intermission before, it just ignores the for loop. When I print it, it just goes down. when I fire it to a screen GUI, apparently it works, even if intermission is 200 away from where it should be.

2 comments

0

while it doesn't seem like so, intermission is a local variable, meaning it is only accessible within its scope

0

have you tried defining intermission before then doing start() after the function?