Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't the while function not working?

This is a server script inside a text label which updates the text label and spawns zombies, The script works but when I update the hello value to 11 the script keep going?

local b = game.Workspace.Hello.Value
	
	while b == 10 do
        wait(40)
        
		script.Parent.Text = "20"
end

2 answers

✓ Accepted answer
local b = game.Workspace.Hello.Value

    while b == 10 do
        wait(40)

        script.Parent.Text = "20"
	b = game.Workspace.Hello.Value
end

You need to update b's value each time.

OR

local b = game.Workspace.Hello

    while b.Value == 10 do
        wait(40)

        script.Parent.Text = "20"
end

OR

    while game.Workspace.Hello.Value == 10 do
        wait(40)

        script.Parent.Text = "20"
end

3 comments

0

Ill try it

0

Thx it worked

0

np

Hello! This should do it.

local b = game.Workspace.Hello
   while b.Value == 10 do
        wait(40)

        script.Parent.Text = "20"
end

Your script kept going as you saved the value in the beginning, and the script doesn't see if you changed it or not, but this script does check.

5 comments

0

thats what I said

0

Ill try it

0

Also theres no point in putting the value in the second script when you could just put it in one script at line 1

0

said that too

0

@JesseSong you want to make the script neat, so in the future you could change the variable name and it will still work.

This discussion is preserved as it was. New answers, comments, and votes are closed.