So I have a meltdown function, this is for a Sci-Fi core game I'm making. There is a button that shuts down the core like Emergency Shutdown type thing. What I'm trying to accomplish is the script stopping where it is and letting the shutdown script continue. Like no matter what line it's on I want it to stop. I have tried a BoolValue.Changed function but that didn't work. This method is invoked by a BindableEvent. Here's my code so far: (note that every separation of lua code blocks is a different script, it's not all in one)
MeltdownStart = function()
Functions.MeltdownStage1()
end,
MeltdownStage1 = function()
sss.Game.Values.Events.MeltdownStage.Value = 1
sss.Game.Values.Events.Shutdown.Changed:Connect(function()
return
end)
----------------------
game.ServerScriptService.Game.Values.Events.Meltdown.Value = true
game.ReplicatedStorage.Game.Events.SendEpWarning:FireAllClients()
wait(6)
workspace.Audios.Music.MeltdownIncome:Play()
wait(50)
workspace.Audios.Music.MeltdownIncome:Stop()
----------------------
workspace.Audios.Effects.Alarms.AlarmDburr.Volume=2
workspace.Audios.Effects.Alarms.AlarmDburr:Play()
LCMS.MeltdownPowerglitch()
workspace.Audios.Effects.Alarms.AlarmDburr:Stop()
wait(10)
workspace.Reactor.MeltdownSmokePart.Smoke.Enabled=true -- smoke uwu
workspace.Audios.Effects.Explosions.Explosion3:Play()
workspace.MeltdownEvents.Values.LiquidHBreach.Value=true
sss.Meltdown.ScreenWarnings.Value = true
game.ReplicatedStorage.Shake.Value=40
wait(3)
game.ReplicatedStorage.Shake.Value=0
LCMS.AlarmsOperations(2)
workspace.Audios.RFAS.Meltdown_Evac.Volume = 2
workspace.Audios.RFAS.Meltdown_Evac:Play()
workspace.Audios.Music.MusicLiveFireExercise:Play()-- 113
wait(23)
workspace.Audios.Explosion.Explosion1:Play()
game.ServerScriptService.Meltdown["ViewingPlatform Explode"].Disabled=false
wait(10)
workspace.Audios.Explosion.Explosion3:Play()
game.ServerScriptService.Meltdown["Tranformer Explode2"].Disabled=false
game.ReplicatedStorage.Shake.Value=40
wait(3)
game.ReplicatedStorage.Shake.Value=0
---- IMPUT rFFA ERROR HERE
wait(74)
workspace.Audios.Explosion.Explosion3:Play()
game.ReplicatedStorage.Shake.Value=40
game.ServerScriptService.Meltdown["Tranformer Explode"].Disabled=false
wait(3)
Functions.MeltdownStage2()
end,
MeltdownStage2 = function()
---START OF STAGE 2 MELTDOWN
sss.Game.Values.Events.MeltdownStage.Value = 2
workspace.Audios.Music.MusicPreciousMoon:Play() -- 105
game.ReplicatedStorage.Shake.Value=0
workspace.BreakGlass.Anchored=false
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "ReactorTV" then
for k,l in pairs(v:GetChildren()) do
if v.Name ~= "REGEN_TOGGLE" then
l.Anchored = false
end
end
end
end
wait(29)
wait(40)
workspace.Audios.Explosion.Explosion1:Play()
workspace.Logo.Anchored=false
workspace.Logo2.Anchored=false
workspace.Logo3.Anchored=false
workspace.Logo4.Anchored=false
workspace.Logo5.Anchored=false
Functions.Destruction("WallExplode")
LCMS.PowerDown()
workspace.Audios.Effects.PowerGlitch.PowerdownSE:Play()
game.ReplicatedStorage.Shake.Value=40
wait(3)
game.ReplicatedStorage.Shake.Value=0
wait(30)
workspace.Audios.Explosion.Explosion3:Play()
wait(4)
Functions.MeltdownStage3()
end,
MeltdownStage3 = function()
sss.Game.Values.Events.MeltdownStage.Value = 3
workspace.Audios.Music.MusicFriendlyFaithPlate:Play()
wait(30)
workspace.Audios.Explosion.Explosion4:Play()
game.ReplicatedStorage.Shake.Value=120
wait(3)
game.ReplicatedStorage.Shake.Value=0
wait(40)
workspace.Audios.Explosion.Explosion1:Play()
game.ReplicatedStorage.Shake.Value = 120
wait(3)
game.ReplicatedStorage.Shake.Value = 0
wait(41)
Functions.CoreBoom()
end,
CoreBoom = function()
sss.Game.Values.Events.MeltdownStage.Value = 4
workspace.Audios.Effects.Explosions.Explosion_MainStream:Play()
game.ReplicatedStorage.Shake.Value=500
wait(1.4)
workspace.CoreBoom.Grow.Disabled=false
workspace.Audios.Effects.Explosions.Explosion3:Play()
wait(3)
workspace.Audios.Effects.Ambience.ring:Play()
game.ReplicatedStorage.Shake.Value=0
GCMS.FadeAllScreens(255,255,255,.2)
wait(10)
GCMS.UnfadeAllScreens(1)
for i,v in pairs(game.Players:GetPlayers()) do
v.PlayerGui.EndScroll.Frame.LocalScript.Disabled = false
end
end
Button:
local Values = script.Parent.Parent.Values
local db = false
script.Parent.ClickDetector.MouseClick:Connect(function()
if db then return end
local Key1 = Values.Key1Turned.Value
local Key2 = Values.Key2Turned.Value
db = true
if (Key1 and Key2) == true then
if game.ServerScriptService.Game.Values.Events.MeltdownStage.Value ~= 1 then
script.Parent.Failure:Play()
wait(1)
db = false
return
end
script.Parent.Click:Play()
game.ServerStorage.Bindables.ReactorFunctions:Invoke("Shutdown")
script.Parent.Color = Color3.fromRGB(0,255,0)
script.Parent.ClickDetector.MaxActivationDistance = 0
wait(1)
db = false
else
script.Parent.Failure:Play()
wait(1)
db = false
end
end)
Shutdown:
Shutdown = function()
sss.Game.Values.Events.Shutdown.Value = true
local ScreenVal = workspace.ReactorTVShutdown.Scripts.Screen.Value
ScreenVal = 2
for i,v in pairs(workspace.Audios:GetDescendants()) do
if v:IsA("Sound") then
v:Stop()
end
end
local suspense = workspace.Audios.Music.Suspense
suspense:Play()
wait(30)
local shutdown = math.random(1,2)
local pick = math.random(1,2)
print(shutdown.." Initial value")
print(pick.." Secondary value")
if shutdown ~= pick then
Functions.ShutdownFailure()
ScreenVal = 3
return
elseif shutdown == pick then
Functions.ShutdownSuccess()
ScreenVal = 1
else
Functions.ShutdownFailure()
ScreenVal = 3
end
end,
ShutdownSuccess = function()
script.Parent.Parent.Values.Events.Shutdown.Value = true
workspace.Audios.Music.SuccessfulShutdown:Play()
wait(30)
GCMS.FadeAllScreens(0,0,0,2)
wait(10)
GCMS.UnfadeAllScreens(2)
for i=1.75,0,-0.1 do
workspace.Audios.Music.SuccessfulShutdown.Volume = i
end
workspace.Audios.Music.SuccessfulShutdown:Stop()
wait(2)
GCMS.RollCredits()
end,
ShutdownFailure = function()
workspace.Audios.RFAS.ShutdownFailure.Volume = 2
workspace.Audios.RFAS.ShutdownFailure:Play()
game.ServerStorage.Bindables.MeltdownFunctions:Invoke("MeltdownStage2")
end
