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

This script keeps adding even when <= 38 (for a number value)?

Asked by 5 years ago
Edited 5 years ago

Whenever the number value goes <= 38 it keeps adding then it stops after adding 100 times

This is in a billboard gui

Hierarchy

Script:

script.Parent.Parent.stormwinds.Changed:Connect(function()
    if script.Parent.Parent.stormwinds.Value <= 38 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0
            wait(0.1)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 39 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.001/10
            wait(0.1)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 74 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.01/10
            wait(0.1)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 96 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.01/10
            wait(0.01)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 111 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.02/10
            wait(0.01)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 130 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.03/10
            wait(0.01)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 157 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.04/10
            wait(0.01)
        end
    end
    if script.Parent.Parent.stormwinds.Value >= 500 then
        for i = 1, 100 do
            script.Parent.Value = script.Parent.Value + 0.05/10
            wait(0.01)
        end
    end
end)
0
Why do you want to break on the first iteration of every for loop? Rheines 661 — 5y
0
I was experimenting to see if break does anything, forgot to remove it. LoganboyInCO 150 — 5y
0
I didn't know such a script was possible. User#25115 0 — 5y
0
Whats the fix then? LoganboyInCO 150 — 5y
0
well? LoganboyInCO 150 — 5y

1 answer

Log in to vote
0
Answered by
BenSBk 781 Moderation Voter
5 years ago

It looks like your script will add 0 to the value 100 times with a 0.1 second interval between each addition. If you wish to just not add anything, simply don't check for that possibility. The value will not satisfy any of the other checks and the function will implicitly return.

0
So then whats the fixed loop, im still confused with what the numbers do in for loops. LoganboyInCO 150 — 5y
Ad

Answer this question