Please ignore how messy it is. But i'm trying to work out how the script finds out whether the mini game has ended. It works fine, but i'm trying to add certain features, for example when the last person is left alive they will win the game, instead of my other script still counting to 0 whilst nothing is going on.
But to achieve this I need to find out how the script is ended first of all, and its working out to be quite a task.
Thanks in advance.
disasters = {"ColourDrop","Pitfall","Murderer","SwordFight"}
countdownTime = 45
disasterTime = 10
countdownMessage = "The next disaster will occur in %s seconds."
disasterMessage = "Survive: %s"
items = {}
leaderboard = game.Workspace:findFirstChild("BTS Leaderboard")
local w = game.Workspace:getChildren()
for i=1,#w do
if w[i].Name == "leaderboard" and w[i]:findFirstChild("running") ~= nil and w[i]:findFirstChild("coins") ~= nil then
leaderboard = w[i]
end
wait(0.2)
end
for i=1,#disasters do
local item = game.Lighting:findFirstChild(disasters[i])
if item ~= nil then
item.Parent = nil
table.insert(items, item)
else
print("Error! ", disasters[i], " was not found!")
end
wait(0.2)
end
function chooseDisaster()
return items[math.random(#items)]
end
function sethint(text)
local hint = game.Workspace:findFirstChild("hint")
if (hint ~= nil) then
hint.Text = text
else
print("Hint does not exist, creating...")
h = Instance.new("Hint")
h.Name = "hint"
h.Text = text
h.Parent = game.Workspace
end
end
function removeHint()
hint = game.Workspace:findFirstChild("hint")
if (hint ~= nil) then hint:remove() end
end
function countdown(time)
while (time > 0) do
wait(1)
time = time - 1
_G.countdowngo = ("Game starting in: "..time)
end
removeHint()
return true
end
while true do
countdown(countdownTime)
_G.countdowngo=countdownTime
if leaderboard ~= nil and leaderboard:findFirstChild("running") and leaderboard:findFirstChild("coins") then
leaderboard.coins.Value = 5
leaderboard.running.Value = true
end
local m = chooseDisaster():clone()
if disasterMessage ~= nil then
_G.countdowngo = ("Game: ".. m.Name)
wait(2)
end
m.Parent = game.Workspace
m:makeJoints()
wait(disasterTime)
m:remove()
if leaderboard ~= nil then
leaderboard.running.Value = false
end
wait(0.2)
end

1 comment
At the end