KittenPixel

plz hurry

Apr 26th, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.16 KB | None | 0 0
  1. local AlarmSystem = {}
  2. local SoundService = game.Workspace.Sounds
  3. local Permissions = require(game.ServerScriptService.Services.Modules.Permissions)
  4.  
  5. local CollectionService = game:GetService("CollectionService")
  6. local SafeZoneParts = CollectionService:GetTagged("OxyDepSafeZone")
  7. local SafetyZones = {}
  8.  
  9.  
  10. for _, part in ipairs(workspace:GetDescendants()) do
  11. if part:GetAttribute("OxygenSafeZone") then
  12. table.insert(SafetyZones, part)
  13. end
  14. end
  15.  
  16.  
  17. local function isInSafetyZone(Player)
  18. if not Player.Character then
  19. return false
  20. end
  21.  
  22. if Player.Character:FindFirstChild("Oxygen") then
  23. return true
  24. end
  25.  
  26. for _, Zone in ipairs(SafetyZones) do
  27. local humanoidRootPart = Player.Character:FindFirstChild("HumanoidRootPart")
  28. if not humanoidRootPart then
  29. return false
  30. end
  31.  
  32. local WhitelistedParts = { humanoidRootPart }
  33. local Params = OverlapParams.new()
  34. Params.FilterDescendantsInstances = WhitelistedParts
  35. Params.FilterType = Enum.RaycastFilterType.Include
  36.  
  37. local Parts = workspace:GetPartBoundsInBox(Zone.CFrame, Zone.Size, Params)
  38.  
  39. if #Parts >= 1 then
  40. return true
  41. end
  42. end
  43.  
  44. return false
  45. end
  46.  
  47. AlarmSystem.Procedures = {
  48. ClearHorizon = {
  49. Name = "ClearHorizon",
  50. IsActive = false,
  51. CanToggle = true,
  52. IsPrimary = true,
  53. ClearOnDisable = false,
  54. DisableAlarms = true,
  55. DisablePrevious = true,
  56. AnnouncementSound = SoundService.Protocols.ClearHorizon:FindFirstChild("ClearHorizonAnnouncement"),
  57. Permissions = {
  58. ["Group:Main"] = 255
  59. }
  60. },
  61. OrangeFire = {
  62. Name = "OrangeFire",
  63. IsActive = false,
  64. CanToggle = true,
  65. IsPrimary = true,
  66. ClearOnDisable = true,
  67. DisablePrevious = true,
  68. AnnouncementSound = SoundService.Protocols.OrangeFire:FindFirstChild("OrangeFireAnnouncement"),
  69. AlarmSettings = {
  70. Color = Color3.new(1, 0.521569, 0.101961),
  71. BackgroundAmbience = SoundService.Protocols.OrangeFire:FindFirstChild("OrangeFireAmbience"),
  72. },
  73. Permissions = {
  74. ["Group:Main"] = 255
  75. }
  76. },
  77. OxygenDepletion = {
  78. Name = "OxygenDepletion",
  79. IsActive = false,
  80. CanToggle = false,
  81. IsPrimary = false,
  82. ClearOnDisable = false,
  83. DisablePrevious = true,
  84. AnnouncementSound = SoundService.Protocols.OxygenDepletion:FindFirstChild("OxygenDepletionAnnouncement"),
  85. AlarmSettings = {
  86. BackgroundAmbience = SoundService.Protocols.OxygenDepletion:FindFirstChild("OxygenDepletionAmbience"),
  87. },
  88. Permissions = {
  89. ["Group:Main"] = 243
  90. },
  91. EnableServerFunction = function()
  92. game.Workspace.OxygenDep.OxCount.Value = 5
  93. game.Workspace.OxygenDep.DepletionInProgress.Value = true
  94. while game.Workspace.OxygenDep.DepletionInProgress.Value do
  95. warn(game.Workspace.OxygenDep.OxCount.Value)
  96. if game.Workspace.OxygenDep.OxCount.Value == -1 then
  97.  
  98.  
  99. game.Workspace.OxygenDep.Extracting.Value = true
  100. game.Workspace.OxygenDep.DepletionInProgress.Value = false
  101.  
  102. SoundService.Protocols.OxygenDepletion:FindFirstChild("Vacuum"):Play()
  103.  
  104. for _, Player in ipairs(game.Players:GetPlayers()) do
  105. if Player.Character then
  106. local HumanoidRootPart = Player.Character:FindFirstChild("HumanoidRootPart")
  107. local Humanoid = Player.Character:FindFirstChild("Humanoid")
  108. if HumanoidRootPart and Humanoid then
  109. local IsInSafety = isInSafetyZone(Player)
  110. if not IsInSafety or game.Workspace.OxygenDep.AffectShelter.Value == true then
  111. Humanoid:TakeDamage(Humanoid.MaxHealth)
  112. end
  113. end
  114. end
  115. end
  116.  
  117. task.wait(1)
  118. AlarmSystem:ActivateProcedure("OrangeFire", "Server")
  119. end
  120.  
  121. game.Workspace.OxygenDep.OxCount.Value -= 1
  122. task.wait(1)
  123. end
  124. end,
  125. DisableServerFunction = function()
  126. game.Workspace.OxygenDep.OxCount.Value = 5
  127. game.Workspace.OxygenDep.DepletionInProgress.Value = false
  128. end,
  129. },
  130. }
  131.  
  132. function AlarmSystem:GetProcedure(name)
  133. return AlarmSystem.Procedures[name]
  134. end
  135.  
  136. function AlarmSystem:ListProcedures()
  137. local list = {}
  138. for _, proc in pairs(AlarmSystem.Procedures) do
  139. table.insert(list, proc.Name)
  140. end
  141. return list
  142. end
  143.  
  144. function AlarmSystem:Init()
  145. game.ReplicatedStorage.Events.GetProtocols.OnServerInvoke = function()
  146. return AlarmSystem:ListProcedures()
  147. end
  148.  
  149. game.ServerStorage.Events.GetProtocols.OnInvoke = function()
  150. return AlarmSystem:ListProcedures()
  151. end
  152.  
  153. self:ActivateProcedure("ClearHorizon", "Server")
  154. end
  155.  
  156. function AlarmSystem:DisableAll(primaryOnly)
  157. for _, proc in pairs(AlarmSystem.Procedures) do
  158. if proc.IsActive and (not primaryOnly or proc.IsPrimary) then
  159. AlarmSystem:DeactivateProcedure(proc.Name, "Server")
  160. end
  161. end
  162. end
  163.  
  164. function AlarmSystem:ActivateProcedure(name, player)
  165. local proc = AlarmSystem:GetProcedure(name)
  166. if not proc then
  167. warn("Invalid procedure: " .. tostring(name))
  168. return "Invalid procedure: " .. tostring(name)
  169. end
  170. if player ~= "Server" then
  171. if not Permissions:CanUserAccess(player, proc.Permissions) then
  172. warn("Access denied for " .. player.Name)
  173. return "Access denied for " .. player.Name
  174. end
  175.  
  176. end
  177.  
  178. if proc.IsActive then
  179. warn("Procedure already active: " .. proc.Name)
  180. return "Procedure already active: " .. proc.Name
  181. end
  182.  
  183. if proc.DisableAlarms then
  184. game.Workspace.Alarms.Value = Color3.new(0, 0, 0)
  185. wait(0.4)
  186. game.Workspace.AlarmState.Value = false
  187. else
  188. if proc.AlarmSettings.Color then
  189. game.Workspace.Alarms.Value = proc.AlarmSettings.Color
  190. end
  191. wait(0.4)
  192. game.Workspace.AlarmState.Value = true
  193. end
  194.  
  195. if proc.DisablePrevious then
  196. AlarmSystem:DisableAll()
  197. end
  198.  
  199. proc.IsActive = true
  200.  
  201. if proc.AnnouncementSound then proc.AnnouncementSound:Play() end
  202. if proc.AlarmSettings and proc.AlarmSettings.BackgroundAmbience then
  203. proc.AlarmSettings.BackgroundAmbience:Play()
  204. end
  205.  
  206. coroutine.wrap(function()
  207. if proc.EnableServerFunction then
  208. proc.EnableServerFunction()
  209. end
  210. end)()
  211.  
  212. return proc.Name .. " activated"
  213. end
  214.  
  215. function AlarmSystem:DeactivateProcedure(name, player, clear)
  216. local proc = AlarmSystem:GetProcedure(name)
  217. if not proc then
  218. warn("Invalid procedure: " .. tostring(name))
  219. return "Invalid procedure: " .. tostring(name)
  220. end
  221.  
  222. if not proc.IsActive then
  223. warn("Procedure already inactive: " .. proc.Name)
  224. return "Procedure already inactive: " .. proc.Name
  225. end
  226.  
  227. if player ~= "Server" and proc.Name == "ClearHorizon" then
  228. warn("Unable to disable this protocol as it is a primary protocol")
  229. return "Unable to disable this protocol as it is a primary protocol"
  230. end
  231.  
  232. if player ~= "Server" and not Permissions:CanUserAccess(player, proc.Permissions) then
  233. warn("Access denied for " .. player.Name)
  234. return "Access denied for " .. player.Name
  235. end
  236.  
  237. if clear and proc.ClearOnDisable then
  238. AlarmSystem:ActivateProcedure("ClearHorizon", player)
  239. end
  240.  
  241. proc.IsActive = false
  242.  
  243. if proc.AnnouncementSound then proc.AnnouncementSound:Stop() end
  244. if proc.AlarmSettings and proc.AlarmSettings.BackgroundAmbience then
  245. proc.AlarmSettings.BackgroundAmbience:Stop()
  246. end
  247.  
  248. coroutine.wrap(function()
  249. if proc.DisableServerFunction then
  250. proc.DisableServerFunction()
  251. end
  252. end)()
  253.  
  254. return proc.Name .. " deactivated"
  255. end
  256.  
  257. return AlarmSystem
  258.  
Advertisement
Add Comment
Please, Sign In to add comment