Advertisement
Guest User

PrisonerBoundaryHandler

a guest
May 27th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. local ZonePlus = require(4664437268) -- Initiate Zone+
  2. local ZoneService = require(ZonePlus.ZoneService) -- Retrieve and require ZoneService
  3. local NOT_CELL_TIME = workspace.Boundaries.NotCellTime -- A container (i.e. Model or Folder) of parts that represent the zone
  4. local zone_1 = ZoneService:createZone("NotCellTimeBoundaries", NOT_CELL_TIME, 15) -- Construct a zone called 'ZoneName' using 'group' and with an extended height of 15
  5. local CELL_TIME = workspace.Boundaries.CellTime -- A container (i.e. Model or Folder) of parts that represent the zone
  6. local zone_2 = ZoneService:createZone("CellTimeBoundaries", CELL_TIME, 15) -- Construct a zone called 'ZoneName' using 'group' and with an extended height of 15
  7.  
  8. local function Between(input, num1, num2)
  9. if input >= num1 and input <= num2 then
  10. return true
  11. end
  12. end
  13.  
  14. -- Zone 1 (Not Cell Time)
  15. zone_1.playerAdded:Connect(function(player)
  16. local char = player.Character or player.CharacterAdded:Wait()
  17. local innocent = player.PrisonerStats.Innocent
  18. local clockTime = game:GetService('Lighting').ClockTime
  19.  
  20. if player.Team == game:GetService('Teams').Prisoners and not innocent.Value and not Between(clockTime, 0, 7) then
  21. print(player.Name,"entered the zone 1! Make player innocent. -- NOT CELL TIME")
  22.  
  23. if char.Head:FindFirstChild('Not Innocent') then
  24. char.Head['Not Innocent']:Destroy()
  25. end
  26.  
  27. player.PrisonerStats.Innocent.Value = true
  28. end
  29. end)
  30. zone_1.playerRemoving:Connect(function(player)
  31. local char = player.Character or player.CharacterAdded:Wait()
  32. local innocent = player.PrisonerStats.Innocent
  33. local clockTime = game:GetService('Lighting').ClockTime
  34.  
  35. if player.Team == game:GetService('Teams').Prisoners and not char.Head:FindFirstChild('Not Innocent') and not Between(clockTime, 0, 7) then
  36. print(player.Name,"exited the zone 1! Make player guilty.")
  37.  
  38. local UI = game.ReplicatedStorage.TSIC["Not Innocent"]:Clone()
  39. UI.Parent = char.Head
  40.  
  41. innocent.Value = false
  42. end
  43. end)
  44.  
  45. -- Zone 2 (Cell Time)
  46. zone_2.playerAdded:Connect(function(player)
  47. local char = player.Character or player.CharacterAdded:Wait()
  48. local innocent = player.PrisonerStats.Innocent
  49. local clockTime = game:GetService('Lighting').ClockTime
  50.  
  51. if player.Team == game:GetService('Teams').Prisoners and innocent.Value and Between(clockTime, 0, 7) then
  52. print(player.Name,"entered the zone 2! Make player innocent. -- CELL TIME")
  53.  
  54. if char.Head:FindFirstChild('Not Innocent') then
  55. char.Head['Not Innocent']:Destroy()
  56. end
  57.  
  58. innocent.Value = true
  59. end
  60. end)
  61. zone_2.playerRemoving:Connect(function(player)
  62. local char = player.Character or player.CharacterAdded:Wait()
  63. local innocent = player.PrisonerStats.Innocent
  64. local clockTime = game:GetService('Lighting').ClockTime
  65.  
  66. print(player.Name,"exited the zone 2! -- CELL TIME")
  67.  
  68. if player.Team == game:GetService('Teams').Prisoners and not char.Head:FindFirstChild('Not Innocent') and Between(clockTime, 0, 7) then
  69. print(player.Name,"exited the zone 2! Make player guilty. -- CELL TIME")
  70.  
  71. local UI = game.ReplicatedStorage.TSIC["Not Innocent"]:Clone()
  72. UI.Parent = char.Head
  73.  
  74. innocent.Value = false
  75. end
  76. end)
  77.  
  78. -- Main
  79.  
  80. local zoneOneLooping = false
  81. local zoneTwoLooping = false
  82.  
  83. while (true) do
  84. wait(0.5)
  85.  
  86. local clockTime = game:GetService('Lighting').ClockTime
  87.  
  88. if not Between(clockTime, 0, 7) and not zoneOneLooping and not zoneTwoLooping then -- Not CELLTIME and ZONE 1 not looping and ZONE 2 not looping
  89. print('1')
  90.  
  91. zoneOneLooping = true
  92. zoneTwoLooping = false
  93.  
  94. spawn(function()
  95. zone_1:initLoop()
  96. end)
  97.  
  98. elseif not Between(clockTime, 0, 7) and zoneOneLooping then -- Not CELLTIME and ZONE 1 looping
  99. print('2')
  100.  
  101. -- Do nothing
  102.  
  103. elseif not Between(clockTime, 0, 7) and zoneTwoLooping then -- Not CELLTIME and ZONE 2 looping and ZONE 1 not looping
  104. print('3')
  105.  
  106. zone_2:endLoop()
  107.  
  108. zoneTwoLooping = false
  109. zoneOneLooping = true
  110.  
  111. spawn(function()
  112. zone_1:initLoop()
  113. end)
  114.  
  115. elseif Between(clockTime, 0, 7) and not zoneTwoLooping and not zoneOneLooping then -- CELLTIME and ZONE 2 not looping and ZONE 1 not looping
  116. print('4')
  117.  
  118. zoneTwoLooping = true
  119. zoneOneLooping = false
  120.  
  121. spawn(function()
  122. zone_2:initLoop()
  123. end)
  124.  
  125. elseif Between(clockTime, 0, 7) and zoneTwoLooping then -- CELLTIME and ZONE 2 looping
  126. print('5')
  127.  
  128. -- Do nothing
  129.  
  130. elseif Between(clockTime, 0, 7) and zoneOneLooping and not zoneTwoLooping then -- CELLTIME and ZONE 1 looping and ZONE 2 not looping
  131. print('6')
  132.  
  133. zone_1:endLoop()
  134.  
  135. zoneTwoLooping = true
  136. zoneOneLooping = false
  137.  
  138. spawn(function()
  139. zone_2:initLoop()
  140. end)
  141.  
  142. end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement