Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't the while function not working?

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
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
0
Ill try it FluffySheep46209 369 — 4y
0
Thx it worked FluffySheep46209 369 — 4y
0
np BabanizPROcuk 49 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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.

0
thats what I said BabanizPROcuk 49 — 4y
0
Ill try it FluffySheep46209 369 — 4y
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 JesseSong 3916 — 4y
0
said that too BabanizPROcuk 49 — 4y
0
@JesseSong you want to make the script neat, so in the future you could change the variable name and it will still work. alexfinger21 341 — 4y

Answer this question