Advertisement
Death_Data

v

Feb 19th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2.  
  3. local CamModel = script.Parent
  4. local Cam = CamModel.Cam
  5. local Hitbox = CamModel.Hitbox
  6.  
  7. local StationPower = game.ReplicatedStorage.StationPower
  8.  
  9. local DetectionPart = CamModel.DetectionPart
  10. local DetectionArea = CamModel.DetectionArea
  11. local LightPart = Cam.LightPart
  12. local LightPart2 = Cam.LightPart2
  13.  
  14. local SignalVal = CamModel.SignalVal
  15. local TargetVal = CamModel.TargetVal
  16. local AvailableVal = CamModel.Available
  17.  
  18. local LastMode = "Off"
  19. local On = false
  20. local CanTween = false
  21.  
  22. local MoveSound = Cam.Move
  23.  
  24. local SearchDistance = 100
  25.  
  26. local Info = TweenInfo.new(0.5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
  27. local Goal1 = {Transparency = 0}
  28. local Goal2 = {Transparency = 1}
  29.  
  30. local TweenOn1 = TweenService:Create(LightPart,Info,Goal1)
  31. local TweenOn2 = TweenService:Create(LightPart2,Info,Goal1)
  32.  
  33. local TweenOff1 = TweenService:Create(LightPart,Info,Goal2)
  34. local TweenOff2 = TweenService:Create(LightPart2,Info,Goal2)
  35.  
  36.  
  37.  
  38. function GetInRegion(part,torso)
  39.  
  40. local function CreateRegion3FromPart(Part)
  41. return Region3.new(Part.Position-(Part.Size/2),Part.Position+(Part.Size/2))
  42. end
  43.  
  44. local region = CreateRegion3FromPart(part)
  45. local playerfound = false
  46. local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge)
  47. local Players = {}
  48.  
  49. for i,Part in pairs(partsInRegion) do
  50. local Humanoid = Part.Parent:FindFirstChildOfClass("Humanoid")
  51. if Humanoid and Humanoid.Health > 0 and Humanoid:IsDescendantOf(torso.Parent) then
  52. return true
  53. end
  54. end
  55. end
  56.  
  57. function move(target)
  58. local dir = (target.Position - Cam.Position).unit
  59. local spawnPos = Cam.Position
  60. local pos = spawnPos + (dir * 1)
  61. Cam:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos - dir)
  62. Cam:findFirstChild("BodyGyro").maxTorque = Vector3.new(1000,1000,1000)
  63. end
  64.  
  65. function moveTo(target)
  66. Cam.BodyPosition.position = target.Position
  67. Cam.BodyPosition.maxForce = Vector3.new(10,10,10) * Cam.Speed.Value
  68. end
  69.  
  70. function findNearestTorso(pos)
  71. local FoundHead = nil
  72. local ClosestDistance = math.huge
  73.  
  74. for i,v in pairs(workspace:GetChildren()) do
  75. if v.ClassName == "Model" then
  76. local Humanoid = v:FindFirstChildOfClass("Humanoid")
  77. local Head = v:FindFirstChild("Head")
  78. if Humanoid and Head and Humanoid.Health >0 then
  79. local Magnitude = (Head.Position - pos).Magnitude
  80. if Magnitude <100 and Magnitude <ClosestDistance then
  81. local FindRegion = GetInRegion(DetectionArea,Head)
  82. if FindRegion == true then
  83. ClosestDistance = Magnitude
  84. FoundHead = Head
  85. end
  86. end
  87. end
  88. end
  89. end
  90.  
  91. return FoundHead
  92. end
  93.  
  94. function SoundCheck()
  95. --MoveSound.PlaybackSpeed = math.random(900,1100) / 1000
  96. local RotVelocity = Cam.RotVelocity.Magnitude
  97. if RotVelocity > 0.1 then
  98. if MoveSound.Volume <=0 then
  99. MoveSound:Play()
  100. MoveSound.Volume = 0.5
  101. MoveSound.TimePosition = math.random(10,20)
  102. end
  103. else
  104. MoveSound.Volume = 0
  105. -- TweenOff:Play()
  106. end
  107. end
  108.  
  109. function Signal()
  110. local Rake = workspace:FindFirstChild("Rake")
  111. if CamModel.Available.Value == true and Rake then
  112. local RakeTorso = Rake:FindFirstChild("Torso")
  113. if Rake ~= nil and RakeTorso ~= nil and (RakeTorso.Position - Cam.Position).Magnitude <40 then
  114. wait(math.random(200,600)/ 100) do
  115. SignalVal.Value = false
  116. wait(math.random(100,400)/100)
  117. SignalVal.Value = true
  118. end
  119. end
  120. else
  121. SignalVal.Value = true
  122. end
  123. end
  124.  
  125. while true do
  126. wait(0.15)
  127. SoundCheck()
  128. Signal()
  129.  
  130. local FoundTorso = findNearestTorso(DetectionPart.Position)
  131.  
  132. if LastMode == "On" and On == false then
  133. LastMode = "Off"
  134. TweenOff1:Play()
  135. TweenOff2:Play()
  136. elseif LastMode == "Off" and On == true then
  137. LastMode = "On"
  138. Cam.Beep:Play()
  139. TweenOn1:Play()
  140. TweenOn2:Play()
  141. end
  142. if StationPower.Value == true then
  143. if CamModel:FindFirstChild("OnCam") and CamModel.Available.Value == true then
  144. On = true
  145. if FoundTorso~=nil and FoundTorso.Parent ~= nil then
  146. TargetVal.Value = FoundTorso.Parent
  147. move(FoundTorso)
  148. moveTo(FoundTorso)
  149. Cam.Speed.Value = 0.2
  150. else
  151. Cam.Speed.Value = 0.1
  152. FoundTorso = CamModel.DefaultPosition
  153. move(FoundTorso)
  154. moveTo(FoundTorso)
  155. TargetVal.Value = nil
  156. end
  157. else
  158. On = false
  159. Cam.Speed.Value = 0.01
  160. FoundTorso = CamModel.DefaultPosition
  161. move(FoundTorso)
  162. moveTo(FoundTorso)
  163. TargetVal.Value = nil
  164. end
  165. end
  166. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement