Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TweenService = game:GetService("TweenService")
- local CamModel = script.Parent
- local Cam = CamModel.Cam
- local Hitbox = CamModel.Hitbox
- local StationPower = game.ReplicatedStorage.StationPower
- local DetectionPart = CamModel.DetectionPart
- local DetectionArea = CamModel.DetectionArea
- local LightPart = Cam.LightPart
- local LightPart2 = Cam.LightPart2
- local SignalVal = CamModel.SignalVal
- local TargetVal = CamModel.TargetVal
- local AvailableVal = CamModel.Available
- local LastMode = "Off"
- local On = false
- local CanTween = false
- local MoveSound = Cam.Move
- local SearchDistance = 100
- local Info = TweenInfo.new(0.5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
- local Goal1 = {Transparency = 0}
- local Goal2 = {Transparency = 1}
- local TweenOn1 = TweenService:Create(LightPart,Info,Goal1)
- local TweenOn2 = TweenService:Create(LightPart2,Info,Goal1)
- local TweenOff1 = TweenService:Create(LightPart,Info,Goal2)
- local TweenOff2 = TweenService:Create(LightPart2,Info,Goal2)
- function GetInRegion(part,torso)
- local function CreateRegion3FromPart(Part)
- return Region3.new(Part.Position-(Part.Size/2),Part.Position+(Part.Size/2))
- end
- local region = CreateRegion3FromPart(part)
- local playerfound = false
- local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge)
- local Players = {}
- for i,Part in pairs(partsInRegion) do
- local Humanoid = Part.Parent:FindFirstChildOfClass("Humanoid")
- if Humanoid and Humanoid.Health > 0 and Humanoid:IsDescendantOf(torso.Parent) then
- return true
- end
- end
- end
- function move(target)
- local dir = (target.Position - Cam.Position).unit
- local spawnPos = Cam.Position
- local pos = spawnPos + (dir * 1)
- Cam:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos - dir)
- Cam:findFirstChild("BodyGyro").maxTorque = Vector3.new(1000,1000,1000)
- end
- function moveTo(target)
- Cam.BodyPosition.position = target.Position
- Cam.BodyPosition.maxForce = Vector3.new(10,10,10) * Cam.Speed.Value
- end
- function findNearestTorso(pos)
- local FoundHead = nil
- local ClosestDistance = math.huge
- for i,v in pairs(workspace:GetChildren()) do
- if v.ClassName == "Model" then
- local Humanoid = v:FindFirstChildOfClass("Humanoid")
- local Head = v:FindFirstChild("Head")
- if Humanoid and Head and Humanoid.Health >0 then
- local Magnitude = (Head.Position - pos).Magnitude
- if Magnitude <100 and Magnitude <ClosestDistance then
- local FindRegion = GetInRegion(DetectionArea,Head)
- if FindRegion == true then
- ClosestDistance = Magnitude
- FoundHead = Head
- end
- end
- end
- end
- end
- return FoundHead
- end
- function SoundCheck()
- --MoveSound.PlaybackSpeed = math.random(900,1100) / 1000
- local RotVelocity = Cam.RotVelocity.Magnitude
- if RotVelocity > 0.1 then
- if MoveSound.Volume <=0 then
- MoveSound:Play()
- MoveSound.Volume = 0.5
- MoveSound.TimePosition = math.random(10,20)
- end
- else
- MoveSound.Volume = 0
- -- TweenOff:Play()
- end
- end
- function Signal()
- local Rake = workspace:FindFirstChild("Rake")
- if CamModel.Available.Value == true and Rake then
- local RakeTorso = Rake:FindFirstChild("Torso")
- if Rake ~= nil and RakeTorso ~= nil and (RakeTorso.Position - Cam.Position).Magnitude <40 then
- wait(math.random(200,600)/ 100) do
- SignalVal.Value = false
- wait(math.random(100,400)/100)
- SignalVal.Value = true
- end
- end
- else
- SignalVal.Value = true
- end
- end
- while true do
- wait(0.15)
- SoundCheck()
- Signal()
- local FoundTorso = findNearestTorso(DetectionPart.Position)
- if LastMode == "On" and On == false then
- LastMode = "Off"
- TweenOff1:Play()
- TweenOff2:Play()
- elseif LastMode == "Off" and On == true then
- LastMode = "On"
- Cam.Beep:Play()
- TweenOn1:Play()
- TweenOn2:Play()
- end
- if StationPower.Value == true then
- if CamModel:FindFirstChild("OnCam") and CamModel.Available.Value == true then
- On = true
- if FoundTorso~=nil and FoundTorso.Parent ~= nil then
- TargetVal.Value = FoundTorso.Parent
- move(FoundTorso)
- moveTo(FoundTorso)
- Cam.Speed.Value = 0.2
- else
- Cam.Speed.Value = 0.1
- FoundTorso = CamModel.DefaultPosition
- move(FoundTorso)
- moveTo(FoundTorso)
- TargetVal.Value = nil
- end
- else
- On = false
- Cam.Speed.Value = 0.01
- FoundTorso = CamModel.DefaultPosition
- move(FoundTorso)
- moveTo(FoundTorso)
- TargetVal.Value = nil
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement