The script is called on creation, thus the reason why it's changing (or it's rather an illusion) when you enter the level. You are using a timeout loop that you never defined so the if (timeout) part will never be called. Try using
if (created || playerenters)
instead.