Advertisement
spicecode

test980

Jan 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. -- Ajedi32 (Credit this guy more than me.)
  2. -- Kit from TheFurryFox (Credit me if you want.)
  3.  
  4. disasters = {""} -- This is where you list the names models that you want to use for disasters.
  5. -- The list must look like this {"Model","Model","Model","Model","Model"} and so on.
  6. -- Disaster names are case-sensitive and all disaster models must be in the lighting
  7.  
  8. countdownTime = 15 -- The amount of time to wait between each disaster.
  9. disasterTime = 45 -- The ammount of time that the disaster will be in the game before it is removed.
  10.  
  11. countdownMessage = "The next disaster will occur in %s seconds." -- The message displayed between disasters. %s will be replaced with the number of seconds left.
  12. disasterMessage = "Disaster: %s" -- The message displayed when a disaster occurs. %s will be replaced with the disaster name. Set to nil if you do not want a message
  13.  
  14. -- Unless you know what you are doing, please leave the below code alone.
  15. items = {}
  16. leaderboard = game.Workspace:findFirstChild("BTS Leaderboard") -- Used to work with my BTS leaderboard
  17. local w = game.Workspace:getChildren()
  18. for i=1,#w do
  19.     if w[i].Name == "leaderboard" and w[i]:findFirstChild("running") ~= nil and w[i]:findFirstChild("points") ~= ni then
  20.         leaderboard = w[i]
  21.     end
  22. end
  23. for i=1,#disasters do
  24.     local item = game.Lighting:findFirstChild(disasters[i])
  25.     if item ~= nil then
  26.         item.Parent = nil
  27.         table.insert(items, item)
  28.     else
  29.         print("Error! ", disasters[i], " was not found!")
  30.     end
  31. end
  32.  
  33. function chooseDisaster()
  34.     return items[math.random(#items)]
  35. end
  36.  
  37. function sethint(text)
  38.     local hint = game.Workspace:findFirstChild("hint")
  39.     if (hint ~= nil) then
  40.         hint.Text = text
  41.     else
  42.         print("Hint does not exist, creating...")
  43.         h = Instance.new("Hint")
  44.         h.Name = "hint"
  45.         h.Text = text
  46.         h.Parent = game.Workspace
  47.     end
  48.     --print("Hint set to: ", text)
  49. end
  50.  
  51. function removeHint()
  52.     hint = game.Workspace:findFirstChild("hint")
  53.     if (hint ~= nil) then hint:remove() end
  54. end
  55.  
  56. function countdown(time)
  57.     sethint(string.format(countdownMessage, tostring(time)))
  58.     while (time > 0) do
  59.         wait(1)
  60.         time = time - 1
  61.         sethint(string.format(countdownMessage, tostring(time)))
  62.     end
  63.     removeHint()
  64.     return true
  65. end
  66.  
  67. while true do
  68.     countdown(countdownTime)
  69.  
  70.     if leaderboard ~= nil and leaderboard:findFirstChild("running") and leaderboard:findFirstChild("points") then -- For use with my BTS leaderboard.
  71.         leaderboard.points.Value = 30 --Points after you survive disasters.
  72.         leaderboard.running.Value = true
  73.     end
  74.  
  75.     local m = chooseDisaster():clone()
  76.  
  77.     if disasterMessage ~= nil then
  78.         local msg = Instance.new("Message")
  79.         msg.Name = "DisasterMsg"
  80.         msg.Text = string.format(disasterMessage, m.Name)
  81.         msg.Parent = game.Workspace
  82.         wait(3)
  83.         msg.Parent = nil
  84.     end
  85.  
  86.     m.Parent = game.Workspace
  87.     m:makeJoints()
  88.     wait(disasterTime)
  89.     m:remove()
  90.  
  91.     if leaderboard ~= nil then -- For use with the bts leaderboard.
  92.         leaderboard.running.Value = false
  93.     end
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement