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

Is there any way to simplify any parts of this script?

Asked by 10 years ago

Can this script be shortened to to the same stuff but use more loops or things of that nature that would shorten it? Like the countdown and things that just repeat themselves like the explosions and other loops? (I am fairly new to RBX.Lua and scripting in Roblox as a whole so I apologize if I come off as "stupid").

The issue now is it lags out the server and studio to a crash after the script has gotten to Lines 40-42. (I am unsure if it gets to Line 42 because nothing happens after it displays "Ignition" in the Dev Console and as a hint)

Is there a way to make it so that all the script does is loop explosions after I hit a button? Or would that still crash it?

--Also how would I remove the hints after they have been displayed? (currently they are just layering over each other.)

print("Script Active. Waiting Launch.")
local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Ready for Launch."
Main = game.Workspace.Rocket.RocketModel.Head
Top = game.Workspace.Rocket.RocketModel.Head2
Booster = game.Workspace.Rocket.RocketModel.Booster
GantrySide = game.Workspace.Gantry.gantrymiddle.Side
Middle = game.Workspace.Rocket.RocketModel.Middle

game.Workspace.Rocket.Explosiontrigger.ClickDetector.MouseClick:connect(function (onClicked)
 local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 10"
    print("Omicron I Launching in 10")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 9"
    print("Omicron I Launching in 9")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 8"
    print("Omicron I Launching in 8")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 7"
    print("Omicron I Launching in 7")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 6"
    print("Omicron I Launching in 6")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 5"
    print("Omicron I Launching in 5")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 4"
    print("Omicron I Launching in 4")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 3"
    print("Omicron I Launching in 3")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 2"
    print("Omicron I Launching in 2")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launching in 1"
    print("Omicron I Launching in 1")
    wait(1)
    local h = Instance.new("Hint",Workspace) h.Text = "Ignition"
    print("Ignition")
    wait(1)
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 50
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
    wait(1)
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 50
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
if
    Main.Velocity.y > 100
    then
    local h = Instance.new("Hint",Workspace) h.Text = "Liftoff."
    print("Liftoff")
    wait(2)
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 60
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
else
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 60
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
repeat
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 70
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
until Main.Velocity.y > 1000
    wait(2)
    if Main.Velocity.y > 890
    then
    wait(5)
    if Main.Velocity.y > 780
        then
        wait(5)
        explosion = Instance.new("Explosion")
        explosion.BlastRadius = 25
        explosion.BlastPressure = 75
        explosion.DestroyJointRadiusPercent = 0
        explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
        explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
    else
        explosion = Instance.new("Explosion")
        explosion.BlastRadius = 25
        explosion.BlastPressure = 90
        explosion.DestroyJointRadiusPercent = 0
        explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
        explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
        if Main.Velocity.y < 1
            then
            local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            local h = Instance.new("Hint",Workspace) h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            local h = Instance.new("Hint",Workspace) h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            local h = Instance.new("Hint",Workspace) h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            local h = Instance.new("Hint",Workspace) h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)
            local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            local h = Instance.new("Hint",Workspace) h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)         
                print("Catastrophic Failure Imminent. Please Clear the Area.")
                local h = Instance.new("Hint",Workspace) h.Text ="Catastrophic Failure Imminent. Please Clear the Area."
                wait(2)
                print("Systems Failed. Catastrophic Failure Imminent. Please Clear the Area.")
                local h = Instance.new("Hint",Workspace) h.Text ="Systems Failed. Catastrophic Failure Imminent. Please Clear the Area."
                wait(2)
                print("Cooling Systems Failure. Danger Level - Extremely High")
                local h = Instance.new("Hint",Workspace) h.Text = "Cooling Systems Failure. Danger Level - Extremely High"
                wait(2)
                print("Cooling Systems Reboot...")
                local h = Instance.new("Hint",Workspace) h.Text = "Cooling Systems Reboot..."
                explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 50
                    explosion.BlastPressure = 100000
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
                    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
                    wait(1)
                    print("Reboot Failed. Catastrophic Failure Imminent. Please Clear the Area.")
                    local h = Instance.new("Hint",Workspace) h.Text = "Reboot Failed. Catastrophic Failure Imminent. Please Clear the Area."
                    wait(2)
                    explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 15
                    explosion.BlastPressure = 40
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Gantry.Gantrymiddle.Side.Position
                    explosion.Parent = game.Workspace.Gantry.gantrymiddle.Side
                    wait(3)
                    print("Operational Systems Failed. Shutting Down...")
                    local h = Instance.new("Hint",Workspace) h.Text = "Operational Systems Failed. Shutting Down..."
                    wait(2)
                    explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 35
                    explosion.BlastPressure = 95
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Rocket.RocketModel.Middle.Position
                    explosion.Parent = game.Workspace.Rocket.RocketModel.Middle
                    wait(1)
                    explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 40
                    explosion.BlastPressure = 100
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Rocket.RocketModel.Top.Position
                    explosion.Parent = game.Workspace.Rocket.RocketModel.Head2
                    wait(5)
                end
            end
        end
end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Ok, I see multiple errors in this script. :D HERE'S THE FIXED VERSION:

print("Script Active. Waiting Launch.")
local h = Instance.new("Hint",Workspace)
 h.Text = "Omicron I Ready for Launch."
Main = game.Workspace.Rocket.RocketModel.Head
Top = game.Workspace.Rocket.RocketModel.Head2
Booster = game.Workspace.Rocket.RocketModel.Booster
GantrySide = game.Workspace.Gantry.gantrymiddle.Side
Middle = game.Workspace.Rocket.RocketModel.Middle

game.Workspace.Rocket.Explosiontrigger.ClickDetector.MouseClick:connect(function (onClicked)
 h.Text = "Omicron I Launching in 10"
    print("Omicron I Launching in 10")
    wait(1)
    h.Text = "Omicron I Launching in 9"
    print("Omicron I Launching in 9")
    wait(1)
    h.Text = "Omicron I Launching in 8"
    print("Omicron I Launching in 8")
    wait(1)
    h.Text = "Omicron I Launching in 7"
    print("Omicron I Launching in 7")
    wait(1)
    h.Text = "Omicron I Launching in 6"
    print("Omicron I Launching in 6")
    wait(1)
    h.Text = "Omicron I Launching in 5"
    print("Omicron I Launching in 5")
    wait(1)
    h.Text = "Omicron I Launching in 4"
    print("Omicron I Launching in 4")
    wait(1)
    h.Text = "Omicron I Launching in 3"
    print("Omicron I Launching in 3")
    wait(1)
    h.Text = "Omicron I Launching in 2"
    print("Omicron I Launching in 2")
    wait(1)
    h.Text = "Omicron I Launching in 1"
    print("Omicron I Launching in 1")
    wait(1)
    h.Text = "Ignition"
    print("Ignition")
    wait(1)
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 50
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
    wait(1)
print("WE ARE A GO")
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 50
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
if  Main.Velocity.y > 100 then
    h.Text = "Liftoff."
    print("Liftoff")
    wait(2)
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 60
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
h:remove()
else
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 60
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
repeat
    explosion = Instance.new("Explosion")
    explosion.BlastRadius = 25
    explosion.BlastPressure = 70
    explosion.DestroyJointRadiusPercent = 0
    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
until Main.Velocity.y > 1000
    wait(2)
    if Main.Velocity.y > 890
    then
    wait(5)
h:remove()
    if Main.Velocity.y > 780   then
        wait(5)
h:remove()
        explosion = Instance.new("Explosion")
        explosion.BlastRadius = 25
        explosion.BlastPressure = 75
        explosion.DestroyJointRadiusPercent = 0
        explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
        explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
    else
        explosion = Instance.new("Explosion")
        explosion.BlastRadius = 25
        explosion.BlastPressure = 90
        explosion.DestroyJointRadiusPercent = 0
        explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
        explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
        if Main.Velocity.y < 1 then
            h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)local h = Instance.new("Hint",Workspace) h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)
            h.Text = "Omicron I Launch Failed."
            print("Omicron I Launch Failed.")
            wait(2)
            h.Text = "Please contact Launch Administrators."
            print("Please contact Launch Administrators")
            wait(2)         
                print("Catastrophic Failure Imminent. Please Clear the Area.")
                h.Text ="Catastrophic Failure Imminent. Please Clear the Area."
                wait(2)
                print("Systems Failed. Catastrophic Failure Imminent. Please Clear the Area.")
                h.Text ="Systems Failed. Catastrophic Failure Imminent. Please Clear the Area."
                wait(2)
                print("Cooling Systems Failure. Danger Level - Extremely High")
                h.Text = "Cooling Systems Failure. Danger Level - Extremely High"
                wait(2)
                print("Cooling Systems Reboot...")
                h.Text = "Cooling Systems Reboot..."
                explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 50
                    explosion.BlastPressure = 100000
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Rocket.RocketModel.Booster.Position
                    explosion.Parent = game.Workspace.Rocket.RocketModel.Booster
                    wait(1)
                    print("Reboot Failed. Catastrophic Failure Imminent. Please Clear the Area.")
                    h.Text = "Reboot Failed. Catastrophic Failure Imminent. Please Clear the Area."
                    wait(2)
                    explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 15
                    explosion.BlastPressure = 40
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Gantry.Gantrymiddle.Side.Position
                    explosion.Parent = game.Workspace.Gantry.gantrymiddle.Side
                    wait(3)
                    print("Operational Systems Failed. Shutting Down...")
                    h.Text = "Operational Systems Failed. Shutting Down..."
                    wait(2)
                    explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 35
                    explosion.BlastPressure = 95
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Rocket.RocketModel.Middle.Position
                    explosion.Parent = game.Workspace.Rocket.RocketModel.Middle
                    wait(1)
                    explosion = Instance.new("Explosion")
                    explosion.BlastRadius = 40
                    explosion.BlastPressure = 100
                    explosion.DestroyJointRadiusPercent = 95
                    explosion.Position = game.Workspace.Rocket.RocketModel.Top.Position
                    explosion.Parent = game.Workspace.Rocket.RocketModel.Head2
                    wait(5)
h:remove()
                end
            end
        end
end
end)

0
The script does the same exact thing as the other.it gets to line 42/43 and stops there and then crashes the game and studio. areiydenfan00 115 — 10y
0
Oh ok. I will fix it some how. deputychicken 226 — 10y
0
What does it say on output deputychicken 226 — 10y
0
And test this see if it says we are a go deputychicken 226 — 10y
Ad

Answer this question