[SOLVED] I need a script to wait 60 seconds if a clickdetector is pressed, and if it is, run a script, and if it doesnt, run a different script

Basically, what im trying to do is for my core game, make a shutdown button that has a chance to work and has a chance to fail, and if it isn’t pressed, continue on with the script

Here’s a little diagram of what I want

  • Wait 60 seconds for a click detector press (without halting the script)

  • If it is pressed, run a code

[] Randomizer here for the fail or success of the shutdown

{} If it works, run a script
{} if it doesnt work, run a different script

  • If it is not pressed, then continue down the script

I want the press to work within the 60 seconds, not outside or inside the 60 seconds

Heres a path to access the button im talking about

workspace.ShutdownButton.Buttons.Main_Power_Button.ClickDetector

function executeCode()
–stuffhere
end

workspace.ShutdownButton.Buttons.Main_Power_Button.ClickDetector.MouseClick:Connect(function()
task.wait(60)
executeCode()
end)

it cant halt the script in any way
as i said above, it cant halt the script, it needs to be able to detect the click in the 60 seconds while also waiting for a mouseclick before continuing

i see you got around it, but after the click, it waits 60 seconds before doing anything, which i dont want.

i also made a diagram of how i want it to function

This is one way that you can do it.

local cd = workspace.ShutdownButton.Buttons.Main_Power_Button.ClickDetector

local timeoutTime = 60

local function didWork() -- if the randomizer worked
	print("Success")
end

local function didntWork() -- if it didnt work
	print("Failed")
end

local function onPressed() -- when it is pressed within time
	print("I just got pressed")
	local randNum = Random.new():NextInteger(1, 2)
	if randNum == 1 then
		didWork()
	else
		didntWork()
	end
end

local canWork = true
local cdConn = cd.MouseClick:Connect(function() -- this is the pressed connection
	if canWork then
		onPressed()
	end
end)

local totaltime = 0
local conn
conn = game:GetService("RunService").Heartbeat:Connect(function(dt)
	totaltime += dt
	if totaltime >= timeoutTime then
		-- past time
		print("Timeout")
		canWork = false
		cdConn:Disconnect() -- dont allow any more presses
		conn:Disconnect() -- stop the loop
	end
end)

i tried this but it broke a randomizer on if the startup failed or worked

I don’t exactly know what you mean, so I will need a little more info and maybe the part of your script that is breaking to help you further.

heres the entire script for the startup (with your script plugged in)

function onClicked()
	local Randomizer = math.random(1, 1)
	if Randomizer == 1 then
		print("Startup will fail")
		script.Parent.Buttons.Main_Power_Button.Sound:Play()
		script.Parent.Buttons.Main_Power_Button.PrismaticConstraint.TargetPosition = 0.1
		wait(0.3)
		script.Parent.Buttons.Lock_Indicator.BrickColor = BrickColor.new("Really black")
		script.Parent.Buttons.Main_Power_Button.PrismaticConstraint.TargetPosition = 0
		script.Parent.Buttons.Main.Sound:Play()
		script.Parent.Buttons.Main.HingeConstraint.TargetAngle = 0
		script.Parent.Buttons.Main_Power_Button.ClickDetector.MaxActivationDistance = 0
		script.Parent.Third.Disabled = true

		print("Startup button pressed, beginning startup script")
		local AnnouncerBeep = workspace.Sounds.BAlarm
		local TweenService = game:GetService("TweenService")
		wait(0.5)
		AnnouncerBeep:Play()
		local ReactorSealOpen = TweenService:Create(workspace.Map.ReactorSeal, TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Position = Vector3.new(-557.704, 698.454, 253.196)})
		local ReactorSealClose = TweenService:Create(workspace.Map.ReactorSeal, TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Position = Vector3.new(-557.704, 663.624, 253.196)})
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message1:Play()
		wait(7)
		ReactorSealOpen:Play()
		workspace.Sounds.DoorMoving:Play()
		wait(6)
		workspace.Sounds.StartupMusic:Play()
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0
		wait(2)
		AnnouncerBeep:Play()
		local LasersCharge = TweenService:Create(workspace.Values.LaserLightsUpperValue, TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Value = Color3.new(1,1,1)})
		local StabLasersCharge = TweenService:Create(workspace.Values.StabLasersUpperValue, TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Value = Color3.new(0,1,1)})
		workspace.Sounds.LaserChargeUp:Play()
		LasersCharge:Play()
		StabLasersCharge:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message2:Play()
		wait(7.5)
		workspace.Values.FacilityLightsColor.Value = Color3.new(0.0941176, 0.0941176, 0.0941176)
		workspace.Sounds.LightsOff:Play()
		wait(1.5)
		workspace.Values.ReactorChamberLightsColor.Value = Color3.new(1, 1, 1)
		workspace.Sounds.LightsOn:Play()
		wait(1)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.Success:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message3:Play()
		wait(3.5)
		workspace.Values.ShieldCreationBeamValue.Value = true
		local FieldAppear = TweenService:Create(workspace.CoreForceField, TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Transparency = 0})
		FieldAppear:Play()
		wait(5)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.Success:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message4:Play()
		wait(6)
		AnnouncerBeep:Play()
		wait(1)
		workspace.Values.CoreLineAuraValue.Value = true
		workspace.AnnouncerMessages.StartupMessages.Message5:Play()
		wait(5)
		workspace.Values.ShieldCreationBeamValue.Value = false
		wait(0.5)
		workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser2.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser3.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser4.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser5.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser6.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser7.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser8.Cone.Attachment.Beam.Enabled = true
		local StartupShockwave = TweenService:Create(workspace.Shockwave, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0), {Size = Vector3.new(200, 200, 200), Transparency = 1})
		local CoreAppear = TweenService:Create(workspace.Core, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 0})
		local CoreVFXraise = TweenService:Create(workspace.Sounds.CoreVFX, TweenInfo.new(8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {PlaybackSpeed = 4})
		local ShieldRedify = TweenService:Create(workspace.CoreForceField, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Color = Color3.new(1, 0, 0)})
		ShieldRedify:Play()
		CoreVFXraise:Play()
		CoreAppear:Play()
		StartupShockwave:Play()
		workspace.Core.StartupEmitter.StartParticles.Enabled = true
		workspace.Core.StartupEmitter.StartAura.Enabled = true
		workspace.Sounds.Shockwave:Play()
		wait(3)
		workspace.Sounds.Elec:Play()
		workspace.Core.CoreEffects.Fire1.Enabled = true
		workspace.CoreForceField.Transparency = 1
		wait(2)
		workspace.Sounds.StartupMusic:Pause()
		workspace.Sounds.StartupFailMusic:Play()
		wait(0.2)
		workspace.Values.ReactorChamberLightsColor.Value = Color3.new(0,0,0)
		wait(0.2)
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1,0,0)
		workspace.Values.ReactorChamberLightsColor.Value = Color3.new(1,0,0)
		workspace.Sounds.LightsOn:Play()
		AnnouncerBeep:Play()
		wait(1)
		local CoreVFXSlowRaise = TweenService:Create(workspace.Sounds.CoreVFX, TweenInfo.new(120, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {PlaybackSpeed = 10})
		CoreVFXSlowRaise:Play()
		workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message1:Play()
		workspace.Core.StartupEmitter.StartAura.Enabled = false
		wait(10)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message2:Play()
		local RandomStab = math.random(2, 2)
		wait(11)
		if RandomStab == 1 then
			wait(3)
			local PlaybackSlow = TweenService:Create(workspace.Sounds.CoreVFX, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {PlaybackSpeed = 1})
			CoreVFXSlowRaise:Pause()
			PlaybackSlow:Play()
			workspace.Sounds.StartupFailMusic:Pause()
			wait(6)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message3:Play()
			workspace.Values.ReactorChamberLightsColor.Value = Color3.new(0,0,0)
			wait(0.2)
			workspace.Sounds.LightsOn:Play()
			workspace.Values.LaserLightsControlValue.Value = Color3.new(0,0,0)
			workspace.Values.ReactorChamberLightsColor.Value = Color3.new(1,1,1)
			workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
			workspace.Sounds.StartupMusic.Playing = true
			wait(16)
			workspace.AnnouncerMessages.StartupMessages.Message3:Play()
			workspace.CoreForceField.Color = Color3.new(1,1,1)
			local FieldAppear = TweenService:Create(workspace.CoreForceField, TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Transparency = 0})
			FieldAppear:Play()
			wait(6)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.Success:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.Message7:Play()
			wait(14)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.Message8:Play()
			wait(4)
			workspace.Values.ReactorChamberLightsColor.Value = Color3.new(0,0,0)
			workspace.Sounds.LightsOff:Play()
			wait(1)
			workspace.Values.ReactorChamberLightsColor.Value = Color3.new(1,1,1)
			workspace.Values.FacilityLightsColor.Value = Color3.new(1,1,1)
			workspace.Sounds.LightsOn:Play()
			workspace.Values.LaserLightsControlValue.Value = Color3.new(0,1,0)
			wait(1)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.Message9:Play()
			wait(5)
			local FuelIndicatorOff = TweenService:Create(workspace.Values.LaserLightsUpperValue, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Value = Color3.new(0,0,0)})
			FuelIndicatorOff:Play()

			workspace.Core.StartupEmitter.ParticleEmitter.Enabled = false
		else
			wait(3)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message3b:Play()
			coroutine.wrap(function()
				while true do
					local basePart = workspace.Base
					local corePart = workspace.Core
					local coreEffects = workspace.Core.CoreEffects
					local startupemitter = workspace.Core.StartupEmitter

					-- Calculate the random x, y, z coordinates
					local randomX = math.random(-7, 7)
					local randomY = math.random(-7, 7)
					local randomZ = math.random(-7, 7)

					-- Create a random position Vector3 using the coordinates
					local randomPosition = Vector3.new(randomX, randomY, randomZ)

					-- Tween the part to the new position
					TweenService:Create(corePart, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Position = randomPosition + basePart.Position}):Play()
					TweenService:Create(coreEffects, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Position = randomPosition + basePart.Position}):Play()
					TweenService:Create(startupemitter, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Position = randomPosition + basePart.Position}):Play()

					-- Wait one second
					wait(1)
				end
			end)()
			for i = 1, 2 do
				local CoreLaserNumber = math.random(1, 8)
				local CoreLaser = workspace.CoreLasers["CoreLaser"..CoreLaserNumber]
				while CoreLaserNumber == 1 or CoreLaserNumber == 3 do
					CoreLaserNumber = math.random(1, 8)
					CoreLaser = workspace.CoreLasers["CoreLaser"..CoreLaserNumber]
				end
				local Fire = Instance.new("Fire")

				local Beam = Instance.new("Beam") 
				workspace.Sounds.MiniExplosion:Play()
				Beam.Texture = "http://www.roblox.com/asset/?id=7151778302"
				Beam.TextureSpeed = 5
				Beam.Width0 = 25
				Beam.Width1 = 25
				Beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 255))
				Beam.TextureMode = "Stretch"

				Beam.Attachment0 = workspace.Core.LasersAttachment
				Beam.Attachment1 = CoreLaser.Cone.Attachment
				Fire.Parent = CoreLaser.Cone.Attachment
				Beam.Parent = workspace
				Beam.Brightness = 25

				wait(0.25)
				Beam:Destroy()

				Fire.Heat = 50
				Fire.Size = 25

				CoreLaser.Cone.Attachment.Beam.Enabled = false
				wait(1.5)
			end
			wait(8)
			workspace.Sounds.Alarm:Play()
			wait(2)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message4:Play()
			wait(6)
			AnnouncerBeep:Play()
			wait(1)
			workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message5:Play()
			workspace.Sounds.StartupFailMusic:Pause()
			workspace.Sounds.StartupFailMusic2:Play()
			wait(7)	
			workspace.Sounds.LightsOn:Play()
			workspace.Values.FacilityLightsColor.Value = Color3.new(1,0,0)
			wait(3)
			workspace["Shutdown Button"].First.Enabled = true
			workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message10:Play()
			workspace["Shutdown Button"].Buttons.Main_Power_Button.ClickDetector.MouseClick:Wait(60)
			local cd = workspace.ShutdownButton.Buttons.Main_Power_Button.ClickDetector

			local timeoutTime = 60

			local function didWork() -- if the randomizer worked
				print("Success")
			end

			local function didntWork() -- if it didnt work
				print("Failed")
			end

			local function onPressed() -- when it is pressed within time
				print("I just got pressed")
				local randNum = Random.new():NextInteger(1, 2)
				if randNum == 1 then
					didWork()
				else
					didntWork()
				end
			end

			local canWork = true
			local cdConn = cd.MouseClick:Connect(function() -- this is the pressed connection
				if canWork then
					onPressed()
				end
			end)

			local totaltime = 0
			local conn
			conn = game:GetService("RunService").Heartbeat:Connect(function(dt)
				totaltime += dt
				if totaltime >= timeoutTime then
					-- past time
					print("Timeout")
					canWork = false
					cdConn:Disconnect() -- dont allow any more presses
					conn:Disconnect() -- stop the loop
				end
			end)
				wait(8)
				workspace.Core.CoreEffects.Fire2.Enabled = true
				wait(4)
				AnnouncerBeep:Play()
				wait(1)
				workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message6:Play()
				wait(7)
				workspace.Values.FireSupresValue.Value = true
				wait(5)
				AnnouncerBeep:Play()
				wait(1)
				workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message7:Play()
				wait(8)
				AnnouncerBeep:Play()
				TweenService:Create(workspace.Core, TweenInfo.new(20, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Size = Vector3.new(22, 22, 22)}):Play()
				TweenService:Create(workspace.Core.StartupEmitter, TweenInfo.new(20, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Size = Vector3.new(22, 22, 22)}):Play()
				TweenService:Create(workspace.Core.CoreEffects, TweenInfo.new(20, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Size = Vector3.new(22, 22, 22)}):Play()
				wait(1)
				workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message8:Play()
				wait(14)
				AnnouncerBeep:Play()
				workspace.Values.FireSupresValue.Value = false
				wait(1)
				workspace.AnnouncerMessages.StartupMessages.StartupFailMessages.Message9:Play()
				wait(10)
			end
		end
	else
		print("Startup will succeed")
		script.Parent.Buttons.Main_Power_Button.Sound:Play()
		script.Parent.Buttons.Main_Power_Button.PrismaticConstraint.TargetPosition = 0.1
		wait(0.3)
		script.Parent.Buttons.Lock_Indicator.BrickColor = BrickColor.new("Really black")
		script.Parent.Buttons.Main_Power_Button.PrismaticConstraint.TargetPosition = 0
		script.Parent.Buttons.Main.Sound:Play()
		script.Parent.Buttons.Main.HingeConstraint.TargetAngle = 0
		script.Parent.Buttons.Main_Power_Button.ClickDetector.MaxActivationDistance = 0
		script.Parent.Third.Disabled = true
		
		print("Startup button pressed, beginning startup script")
		local AnnouncerBeep = workspace.Sounds.BAlarm
		local TweenService = game:GetService("TweenService")
		wait(0.5)
		AnnouncerBeep:Play()
		local ReactorSealOpen = TweenService:Create(workspace.Map.ReactorSeal, TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Position = Vector3.new(-557.784, 698.085, 243.53)})
		local ReactorSealClose = TweenService:Create(workspace.Map.ReactorSeal, TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Position = Vector3.new(-557.784, 663.624, 243.53)})
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message1:Play()
		wait(7)
		ReactorSealOpen:Play()
		workspace.Sounds.DoorMoving:Play()
		wait(6)
		workspace.Sounds.StartupMusic:Play()
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 1
		workspace.Values.LaserLightsControlValue.Value = Color3.new(1, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0.5
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0, 0, 0)
		wait(0.5)
		workspace.Sounds.Alarm2.PlaybackSpeed = 0
		wait(2)
		AnnouncerBeep:Play()
		local LasersCharge = TweenService:Create(workspace.Values.LaserLightsUpperValue, TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Value = Color3.new(1,1,1)})
		local StabLasersCharge = TweenService:Create(workspace.Values.StabLasersUpperValue, TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Value = Color3.new(0,1,1)})
		workspace.Sounds.LaserChargeUp:Play()
		LasersCharge:Play()
		StabLasersCharge:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message2:Play()
		wait(7.5)
		workspace.Values.FacilityLightsColor.Value = Color3.new(0.0941176, 0.0941176, 0.0941176)
		workspace.Sounds.LightsOff:Play()
		wait(1.5)
		workspace.Values.ReactorChamberLightsColor.Value = Color3.new(1, 1, 1)
		workspace.Sounds.LightsOn:Play()
		wait(1)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.Success:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message3:Play()
		wait(3.5)
		workspace.Values.ShieldCreationBeamValue.Value = true
		local FieldAppear = TweenService:Create(workspace.CoreForceField, TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0), {Transparency = 0})
		FieldAppear:Play()
		wait(5)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.Success:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message4:Play()
		wait(6)
		AnnouncerBeep:Play()
		wait(1)
		workspace.Values.CoreLineAuraValue.Value = true
		workspace.AnnouncerMessages.StartupMessages.Message5:Play()
		wait(5)
		workspace.Values.ShieldCreationBeamValue.Value = false
		wait(0.5)
		workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser2.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser3.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser4.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser5.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser6.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser7.Cone.Attachment.Beam.Enabled = true
		workspace.CoreLasers.CoreLaser8.Cone.Attachment.Beam.Enabled = true
		local StartupShockwave = TweenService:Create(workspace.Shockwave, TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0), {Size = Vector3.new(112.454, 112.454, 112.454), Transparency = 1})
		local CoreAppear = TweenService:Create(workspace.Core, TweenInfo.new(8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 0})
		local CoreVFXraise = TweenService:Create(workspace.Sounds.CoreVFX, TweenInfo.new(8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {PlaybackSpeed = 1})
		CoreVFXraise:Play()
		CoreAppear:Play()
		StartupShockwave:Play()
		workspace.Core.StartupEmitter.StartParticles.Enabled = true
		workspace.Core.StartupEmitter.StartAura.Enabled = true
		workspace.Sounds.Shockwave:Play()
		wait(9)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message6:Play()
		workspace.Core.StartupEmitter.StartAura.Enabled = false
		wait(8)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message7:Play()
		wait(14)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message8:Play()
		wait(4)
		workspace.Values.ReactorChamberLightsColor.Value = Color3.new(0,0,0)
		workspace.Sounds.LightsOff:Play()
		wait(1)
		workspace.Values.ReactorChamberLightsColor.Value = Color3.new(1,1,1)
		workspace.Values.FacilityLightsColor.Value = Color3.new(1,1,1)
		workspace.Sounds.LightsOn:Play()
		workspace.Values.LaserLightsControlValue.Value = Color3.new(0,1,0)
		wait(1)
		AnnouncerBeep:Play()
		wait(1)
		workspace.AnnouncerMessages.StartupMessages.Message9:Play()
		wait(5)
		workspace.Core.StartupEmitter.StartParticles.Enabled = false
		workspace.Values.ReactorCoreIsActive.Value = true
		workspace.Values.ShutdownCmdWorks.Value = true
	end
	
end

script.Parent.Buttons.Main_Power_Button.ClickDetector.MouseClick:Connect(onClicked)

if you need the entire explorer ill provide it
the script above is just to show what ive already coded


the error above only happened when I inserted your script, i presume because you didnt know the entire script

It looks like you accidentally added an extra end at line 358. If you scroll down to that line and delete the end there (It should be underlined red) then it should work.

ill test it right now

filler text

Also, your randomizer will always return 1. You need to do math.random(1, 2) not 1,1

that was intended to test the startup failure

1 Like

still testing, had to stop one test because the core noise was loud

ran into an error on my end, im gonna take a while

i can fix it, a simple name problem

What does the output say, if anything?

it gave no errors with his script

it returned something right, so im gonna assume it works everytime now, but im not gonna mark it as the solution yet because i still need to test the button for all of the possible outcomes

Your code is quite a messy one at first glance, may I know what the goal is?

its a core game, what do you expect?

one half of it is startup fail, the other, succeeding startup.

i made it a guaranteed startup fail to test the startup failure with his codes

i needed a code that would do above in the title