Advertisement
SiegedTrooper

House Fire System

Jul 17th, 2018
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. --[[SCRIPT THAT IS UNDER FIRE INSTANCE]]--
  2.  
  3. NewParent = script.Parent
  4. repeat
  5.     NewParent = NewParent.Parent
  6. until NewParent.Name == "House"
  7.  
  8. script.Parent.Changed:connect(function()
  9.     if not script.Parent.Enabled then
  10.         NewParent.AlarmBlock.AlarmSound:Stop()
  11.     end
  12. end)
  13.  
  14. --[[MAIN SCRIPT]]--
  15.  
  16. wait(1)
  17. RequireFireFighters = true
  18. HowMuchFireFighters = 1
  19. FireTeam = game.Teams["Fire Fighters"]
  20. MinWaitTime = 5
  21. MaxWaitTime = 10
  22. Houses = {}
  23. --SETUP--
  24. for _,i in pairs (workspace.Houses:GetChildren()) do table.insert(Houses,i) end
  25. function SetupA(Object)
  26.     if Object:IsA("Model") then
  27.         for _,i in pairs (Object:GetChildren()) do
  28.             SetupA(i)
  29.         end
  30.     elseif Object:IsA("BasePart") then
  31.         script.Fire:Clone().Parent = Object
  32.         Object:WaitForChild("Fire").Script.Disabled = false
  33.     end
  34. end
  35. for _,i in pairs (Houses) do
  36.     SetupA(i)
  37.     script.AlarmSound:Clone().Parent = i.AlarmBlock
  38. end
  39. --FUNCTION--
  40. function SetupB(Object)
  41.     if Object:IsA("Model") then
  42.         for _,i in pairs (Object:GetChildren()) do
  43.             SetupB(i)
  44.         end
  45.     elseif Object:IsA("BasePart") then
  46.         Object.Fire.Enabled = true
  47.     end
  48. end
  49. while wait(math.random(MinWaitTime,MaxWaitTime)) do
  50.     local allow = true
  51.     if RequireFireFighters then
  52.         allow = false
  53.         local FireFightersFound = 0
  54.         for _,i in pairs (game.Players:GetPlayers()) do
  55.             if i.Team == FireTeam then
  56.                 FireFightersFound = FireFightersFound + 1
  57.             end
  58.         end
  59.         wait()
  60.         if FireFightersFound >= HowMuchFireFighters then
  61.             allow = true
  62.         end
  63.     end
  64.     if allow then
  65.         local Choice = math.random(1,#Houses)
  66.         for _,i in pairs (Houses[Choice]:GetChildren()) do
  67.             SetupB(i)
  68.         end
  69.         Houses[Choice].AlarmBlock.AlarmSound:Play()
  70.     end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement