-
Notifications
You must be signed in to change notification settings - Fork 698
/
Auto Arrest.lua
122 lines (97 loc) · 2.47 KB
/
Auto Arrest.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
local Player = game.Players.LocalPlayer
repeat wait()until Player.Character
local Char = Player.Character
local RootPart = Char.HumanoidRootPart
local Hum = Char.Humanoid
local TargetTeam = game.Teams.Criminal
function LoadChar()
repeat wait()until Player.Character
Char = Player.Character
RootPart = Char.HumanoidRootPart
Hum = Char.Humanoid
end
Player.CharacterAdded:Connect(LoadChar)
local Cam = workspace.CurrentCamera
local Enabled = true
if Player.Name == "Player" or Player.Name == "Player1" then
Enabled = true
end
function GetOffset()
return CFrame.new(0, 0, -1.25)
end
function FPView()
Player.CameraMode = "LockFirstPerson"
end
function ResetView()
Player.CameraMode = "Default"
end
function PointCam(pos)
if typeof(pos) == "CFrame" then
pos = pos.p
end
Cam.CFrame = CFrame.new(Cam.CFrame.p, pos)
end
function TPToTarget(TargetChar)
local player = game.Players:GetPlayerFromCharacter(TargetChar)
if not player then return end
if player.Team == TargetTeam then
local TargetHRP = TargetChar.HumanoidRootPart
local offset = GetOffset()
local pos = TargetHRP.CFrame * offset
RootPart.CanCollide = false
RootPart.CFrame = pos
--RootPart.Anchored = true
Hum.WalkSpeed, Hum.JumpPower = 0, 0
--NoClip(Player)
FPView()
PointCam(TargetHRP.Position)
else
ToNextPlayer()
end
end
local Target = "None"
function GetPlayers(parent)--either game.Players or a team
local plrs = {}
for i,v in pairs(parent:GetPlayers())do
if v then
if v ~= Player and not v:IsInGroup(3172221)then
plrs[#plrs+1] = v
end
end
end
return plrs
end
local index = 0
function ToNextPlayer()
local parent = TargetTeam
local plrs = GetPlayers(parent)
local newindex = index+1
if #plrs>0 then
index = newindex<=#plrs and newindex or 1
Target = plrs[index].Name
end
end
function Step()
local TargetChar = workspace:FindFirstChild(Target)
if TargetChar then
TPToTarget(TargetChar)
end
end
Player:GetMouse().KeyDown:Connect(function(k)
k = k:lower()
if k == "q" then
ToNextPlayer()
end
end)
function Start()
ToNextPlayer()
end
if Enabled then
Start()
--run
game:GetService("RunService").Heartbeat:Connect(function()
if Enabled then
Step()
end
end)
end