R

xhatgpt

public
rrixh May 13, 2024 Never 71
Clone
Plaintext xhatgpt.xls 233 lines (210 loc) | 10.87 KB
1
getgenv().OldAimPart = "Head"
2
getgenv().AimPart = "Head" -- For R15 Games: {UpperTorso, LowerTorso, HumanoidRootPart, Head} | For R6 Games: {Head, Torso, HumanoidRootPart}
3
getgenv().AimlockKey = "c" -- change to whatever you want, make sure it's lowercase
4
getgenv().AimRadius = 500 -- How far away from someone's character you want to lock on at
5
getgenv().ThirdPerson = true
6
getgenv().FirstPerson = true
7
getgenv().TeamCheck = false -- Check if Target is on your Team (True means it won't lock onto your teammates, false is vice versa) (Set it to false if there are no teams)
8
getgenv().PredictMovement = true -- Predicts if they are moving in fast velocity (like jumping) so the aimbot will go a bit faster to match their speed
9
getgenv().PredictionVelocity = 5.9069
10
getgenv().CheckIfJumped = true
11
getgenv().Smoothness = true
12
getgenv().SmoothnessAmount = 1.069
13
14
local Players, Uis, RService, SGui = game:GetService("Players"), game:GetService("UserInputService"), game:GetService("RunService"), game:GetService("StarterGui");
15
local Client, Mouse, Camera, CF, RNew, Vec3, Vec2 = Players.LocalPlayer, Players.LocalPlayer:GetMouse(), workspace.CurrentCamera, CFrame.new, Ray.new, Vector3.new, Vector2.new;
16
local Aimlock, MousePressed, CanNotify = true, false, false;
17
local AimlockTarget;
18
local OldPre;
19
20
21
getgenv().WorldToViewportPoint = function(P)
22
return Camera:WorldToViewportPoint(P)
23
end
24
25
getgenv().WorldToScreenPoint = function(P)
26
return Camera.WorldToScreenPoint(Camera, P)
27
end
28
29
getgenv().GetObscuringObjects = function(T)
30
if T and T:FindFirstChild(getgenv().AimPart) and Client and Client.Character:FindFirstChild("Head") then
31
local RayPos = workspace:FindPartOnRay(RNew(
32
T[getgenv().AimPart].Position, Client.Character.Head.Position)
33
)
34
if RayPos then return RayPos:IsDescendantOf(T) end
35
end
36
end
37
38
getgenv().GetNearestTarget = function()
39
-- Credits to whoever made this, i didnt make it, and my own mouse2plr function kinda sucks
40
local players = {}
41
local PLAYER_HOLD = {}
42
local DISTANCES = {}
43
for i, v in pairs(Players:GetPlayers()) do
44
if v ~= Client then
45
table.insert(players, v)
46
end
47
end
48
for i, v in pairs(players) do
49
if v.Character ~= nil then
50
local AIM = v.Character:FindFirstChild("Head")
51
if getgenv().TeamCheck == true and v.Team ~= Client.Team then
52
local DISTANCE = (v.Character:FindFirstChild("Head").Position - game.Workspace.CurrentCamera.CFrame.p).magnitude
53
local RAY = Ray.new(game.Workspace.CurrentCamera.CFrame.p, (Mouse.Hit.p - game.Workspace.CurrentCamera.CFrame.p).unit * DISTANCE)
54
local HIT,POS = game.Workspace:FindPartOnRay(RAY, game.Workspace)
55
local DIFF = math.floor((POS - AIM.Position).magnitude)
56
PLAYER_HOLD[v.Name .. i] = {}
57
PLAYER_HOLD[v.Name .. i].dist= DISTANCE
58
PLAYER_HOLD[v.Name .. i].plr = v
59
PLAYER_HOLD[v.Name .. i].diff = DIFF
60
table.insert(DISTANCES, DIFF)
61
elseif getgenv().TeamCheck == false and v.Team == Client.Team then
62
local DISTANCE = (v.Character:FindFirstChild("Head").Position - game.Workspace.CurrentCamera.CFrame.p).magnitude
63
local RAY = Ray.new(game.Workspace.CurrentCamera.CFrame.p, (Mouse.Hit.p - game.Workspace.CurrentCamera.CFrame.p).unit * DISTANCE)
64
local HIT,POS = game.Workspace:FindPartOnRay(RAY, game.Workspace)
65
local DIFF = math.floor((POS - AIM.Position).magnitude)
66
PLAYER_HOLD[v.Name .. i] = {}
67
PLAYER_HOLD[v.Name .. i].dist= DISTANCE
68
PLAYER_HOLD[v.Name .. i].plr = v
69
PLAYER_HOLD[v.Name .. i].diff = DIFF
70
table.insert(DISTANCES, DIFF)
71
end
72
end
73
end
74
75
if unpack(DISTANCES) == nil then
76
return nil
77
end
78
79
local L_DISTANCE = math.floor(math.min(unpack(DISTANCES)))
80
if L_DISTANCE > getgenv().AimRadius then
81
return nil
82
end
83
84
for i, v in pairs(PLAYER_HOLD) do
85
if v.diff == L_DISTANCE then
86
return v.plr
87
end
88
end
89
return nil
90
end
91
92
Mouse.KeyDown:Connect(function(a)
93
if not (Uis:GetFocusedTextBox()) then
94
if a == AimlockKey and AimlockTarget == nil then
95
pcall(function()
96
if MousePressed ~= true then MousePressed = true end
97
local Target;Target = GetNearestTarget()
98
if Target ~= nil then
99
AimlockTarget = Target
100
end
101
end)
102
elseif a == AimlockKey and AimlockTarget ~= nil then
103
if AimlockTarget ~= nil then AimlockTarget = nil end
104
if MousePressed ~= false then
105
MousePressed = false
106
end
107
end
108
end
109
end)
110
111
RService.RenderStepped:Connect(function()
112
if getgenv().ThirdPerson == true and getgenv().FirstPerson == true then
113
if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 1 or (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1 then
114
CanNotify = true
115
else
116
CanNotify = false
117
end
118
elseif getgenv().ThirdPerson == true and getgenv().FirstPerson == false then
119
if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 1 then
120
CanNotify = true
121
else
122
CanNotify = false
123
end
124
elseif getgenv().ThirdPerson == false and getgenv().FirstPerson == true then
125
if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1 then
126
CanNotify = true
127
else
128
CanNotify = false
129
end
130
end
131
if Aimlock == true and MousePressed == true then
132
if AimlockTarget and AimlockTarget.Character and AimlockTarget.Character:FindFirstChild(getgenv().AimPart) then
133
if getgenv().FirstPerson == true then
134
if CanNotify == true then
135
if getgenv().PredictMovement == true then
136
if getgenv().Smoothness == true then
137
--// The part we're going to lerp/smoothen \\--
138
local Main = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position + AimlockTarget.Character[getgenv().AimPart].Velocity/PredictionVelocity)
139
140
--// Making it work \\--
141
Camera.CFrame = Camera.CFrame:Lerp(Main, getgenv().SmoothnessAmount, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut)
142
else
143
Camera.CFrame = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position + AimlockTarget.Character[getgenv().AimPart].Velocity/PredictionVelocity)
144
end
145
elseif getgenv().PredictMovement == false then
146
if getgenv().Smoothness == true then
147
--// The part we're going to lerp/smoothen \\--
148
local Main = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position)
149
150
--// Making it work \\--
151
Camera.CFrame = Camera.CFrame:Lerp(Main, getgenv().SmoothnessAmount, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut)
152
else
153
Camera.CFrame = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position)
154
end
155
end
156
end
157
end
158
end
159
end
160
if getgenv().CheckIfJumped == true then
161
if AimlockTarget.Character.Humanoid.FloorMaterial == Enum.Material.Air then
162
163
getgenv().AimPart = "UpperTorso"
164
else
165
getgenv().AimPart = getgenv().OldAimPart
166
167
end
168
end
169
end)
170
171
getgenv().AimPart = "HumanoidRootPart" -- For R15 Games: {UpperTorso, LowerTorso, HumanoidRootPart, Head} | For R6 Games: {Head, Torso, HumanoidRootPart}
172
getgenv().AimlockKey = "c" -- change to whatever you want, make sure it's lowercase
173
getgenv().AimRadius = 500 -- How far away from someone's character you want to lock on
174
getgenv().OrbitDistance = 10 -- Distance from the target
175
getgenv().OrbitSpeed = 2 -- Speed of the orbit
176
177
local Players, Uis, RService = game:GetService("Players"), game:GetService("UserInputService"), game:GetService("RunService")
178
local Client, Mouse, Camera, CF, Vec3 = Players.LocalPlayer, Players.LocalPlayer:GetMouse(), workspace.CurrentCamera, CFrame.new, Vector3.new
179
local Aimlock, MousePressed, AimlockTarget = true, false, nil
180
181
function GetNearestPlayerToCursor()
182
local nearestDistance = getgenv().AimRadius
183
local nearestPlayer = nil
184
local unitRay = Camera:ScreenPointToRay(Mouse.X, Mouse.Y)
185
local rayParams = RaycastParams.new()
186
rayParams.FilterType = Enum.RaycastFilterType.Whitelist
187
rayParams.FilterDescendantsInstances = {workspace}
188
189
for _, player in ipairs(Players:GetPlayers()) do
190
if player ~= Client then
191
local character = player.Character
192
if character and character:FindFirstChild(getgenv().AimPart) then
193
local part = character[getgenv().AimPart]
194
local hit, position = workspace:FindPartOnRayWithIgnoreList(Ray.new(unitRay.Origin, (unitRay.Direction * getgenv().AimRadius)), {character})
195
if hit and (position - part.Position).magnitude < nearestDistance then
196
nearestDistance = (position - part.Position).magnitude
197
nearestPlayer = player
198
end
199
end
200
end
201
end
202
203
return nearestPlayer
204
end
205
206
Mouse.KeyDown:Connect(function(key)
207
if not Uis:GetFocusedTextBox() then
208
if key == getgenv().AimlockKey then
209
if AimlockTarget == nil then
210
AimlockTarget = GetNearestPlayerToCursor()
211
else
212
AimlockTarget = nil
213
end
214
MousePressed = not MousePressed
215
end
216
end
217
end)
218
219
RService.RenderStepped:Connect(function()
220
if Aimlock and MousePressed then
221
if AimlockTarget and AimlockTarget.Character and AimlockTarget.Character:FindFirstChild(getgenv().AimPart) then
222
local targetPosition = AimlockTarget.Character[getgenv().AimPart].Position
223
224
-- Orbit around the target
225
local angle = math.rad(tick() * getgenv().OrbitSpeed * 360)
226
local offsetX = getgenv().OrbitDistance * math.cos(angle)
227
local offsetZ = getgenv().OrbitDistance * math.sin(angle)
228
local orbitPosition = targetPosition + Vector3.new(offsetX, 0, offsetZ)
229
local lookVector = (targetPosition - orbitPosition).unit
230
Client.Character:SetPrimaryPartCFrame(CF(orbitPosition, orbitPosition + lookVector * 10))
231
end
232
end
233
end)