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

Complicated to fit into a title. Help?

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

✓ Accepted answer

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

3 comments

1

Thanks! :D

0

What would be the merit of Spawn over Delay?

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.

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