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

'Disaster' Script not functioning?

Asked by 8 years ago

Alright, so I was messing with a 'Create your own disasters level!' script and I have come across some problems. The original script always had a countdown and the game would not end until the countdown was up. That is all well and good, but I wanted to have some disasters that ended if a certain condition was met. Such as a boss fight. I want to know how to make the disaster end early if the boss dies. There are other conditions for other 'disasters' I still need, but I assume that once one is figured out I can apply that knowledge to the rest. So the goal is to have the disaster countdown continue as it normally would, but to cut it short and end the disaster if a condition is met.

local m = chooseDisaster():clone()
local k = game.Players:getChildren()
        if game.Workspace.Labs ~= nil then
            while k > 1 do
            wait(disastertime)
            while k <= 1 do
                m:remove()
            end
            end
            end
            if game.Workspace.PrimordialTemple ~= nil then
            while k > 1 do
                wait(disastertime)
            while k <= 1 do
                m:remove()
            end
            end
            end
            if game.Workspace.Clocktower ~= nil then
                while k > 0 do
                    wait(disastertime)
                while k == 0 do
                    m:remove()
                end
                end
                end
            if game.Workspace.HalloweenKing ~= nil then
                while k > 0 do
                    wait(disastertime)
                while k == 0 do
                    m:remove()
                while game.Workspace.HalloweenKing.HalloweenKing.Humanoid.Health == 0 do
                    m:remove()
                end
                end
                end
                end
            if game.Workspace.Labrynthe ~= nil then
                while k > 0 do
                    wait(disastertime)
                while k == 0 do
                    m:remove()
                end
                end
                end
            if game.Workspace.ReapersRumble ~= nil then
                while k > 0 do
                    wait(disastertime)
                end
                end
    end

What I was trying to do with the code was to have the game check to see if the map is in Workspace. The maps are loaded from Lighting into Workspace. So once the map is loaded into the Workspace, I tried to write a code that started the countdown as normal, but if a condition was met, it would end the disaster early. If more of the code is required to be shown here, I can post it. Thank you for your time and I hope you can help! :)

0
Oh, I forgot to add the line of code that said disastertime = 180. Sorry about that! Malefactus 55 — 8y

Answer this question