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

Complicated to fit into a title. Help?

Asked by 10 years ago

Okay, the title has nothing to do with the thing I want to fix.

What I want to do is to carry the script on without stopping it at my function add60() Since it is a loop. It won't carry on until it finishes, is there a way to bypass this?

Script:

Temperature=game.Workspace.TemperatureValue
ReactorSafeguards=game.Workspace.ReactorSafeguards
ReactorMeltdownSong=game.Workspace.ReactorMeltdownSong
EmergencyPower=game.Workspace.EmergencyPower
EL1=game.Workspace.ELS.EL1.Toggle
EL2=game.Workspace.ELS.EL2.Toggle

function shake()
    local camera = game.Workspace.CurrentCamera
    for i = 1,10000 do  
        wait()
        camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,2,0)
        wait()
        camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(0,-2,0)
    end 
end 

function add60()
    for i=1, 10 do  -- THIS IS THE FUNCTION WHAT LOOPS
        wait(2)
        script.Parent.TemperatureValue.Value = script.Parent.TemperatureValue.Value +60
    end
    end


while true do
    wait()
if Temperature.Value >= 2000 then
    Temperature.Value = 2001
add60() -- IT STOPS HERE UNTIL IT HAS FINISHED.
    ReactorSafeguards:Play()
    wait(2)
    ReactorMeltdownSong:Play()
    wait(4)
    ReactorSafeguards:Play()
    shake()
    wait(9)
    EmergencyPower:Play()
    wait(1)
    EL1.Value = true
    EL2.Value = true
    break
end
end

1 answer

Log in to vote
0
Answered by
DataStore 530 Moderation Voter
10 years ago

You could remove the wait, or you could use the 'Spawn' function (or a coroutine). In your case, I'd suggest using 'Spawn'.

http://wiki.roblox.com/index.php?title=Function_Dump/Roblox_Specific_Functions#Spawn

1
Thanks! :D WelpNathan 307 — 10y
0
What would be the merit of `Spawn` over `Delay`? BlueTaslem 18071 — 10y
0
They do exactly the same thing essentially, with one difference; Delay executes the given function after a given amount of time has passed, whilst Spawn executes the given function as soon as the thread next yields. So the only merit I can see in this case is less typing, unless you want to add something. DataStore 530 — 10y
Ad

Answer this question