R

lunar

public
rrixh Apr 15, 2024 Never 83
Clone
Plaintext lunarLoxk 201 lines (163 loc) | 5.67 KB
This code appears to be related to a game's aimbot functionality. Here is an analysis of the code: 1. Global Variables: - `Prediction`: Represents the prediction value for aiming. - `Smoothness`: Represents the smoothness of the aim movement. - `AimPart`: Specifies the part of the player model to aim at. - `OldAimpart`: Stores the old value of the aim part. - `ShakeValue`: Represents the amount of shake to apply. - `AutoPred`: Boolean variable that determines if automatic prediction is enabled. 2. Creation of Tool Object: - An instance of `Tool` is created and assigned certain properties like `RequiresHandle`, `Name`, and `Parent`. 3. Event Handling: - A function `connectCharacterAdded` is connected to the `CharacterAdded` event of the player. - An event handler is set up for `CharacterRemoving` event. 4. Service and Regular Variables: - Various game services (Players, RunService, Workspace, GuiService, StarterGui) are fetched. - Local variables are initialized for Player, Mouse, Camera, and others. 5. Notification Function: - A function named `Notify` is defined to display notifications using `StarterGui:SetCore`. 6. Loading and FOV Circle: - Checks if the aimlock has been loaded previously. - A circle for Field of View (FOV) is initialized using Drawing API. 7. Additional Functions: - `update()`: Updates the FOV circle based on settings. - `WTVP()`: Converts world coordinates to viewport. - `WTSP()`: Converts world coordinates to screen. - `getClosest()`: Finds the closest player to the cursor within FOV. 8. Tool Activation and Main Loop: - Tool activation event handler toggles aimlock on/off based on FOV. - `RenderStepped` event loop continuously updates camera position when aimlock is active. 9. Camera Lock and Prediction: - Camera is smoothly locked onto the target player's specified part. - Prediction value is dynamically adjusted based on the network ping. 10. Camera Connections: - Disables certain camera connections using `getconnections`. 11. Automatic Prediction Adjustment: - Continuously adjusts the prediction value based on network ping if `AutoPred` is enabled. Overall, the code sets up an aimbot that locks the camera onto a target player with various functionalities such as FOV, smoothness, prediction adjustments based on ping, and notifications.
1
getgenv().Prediction = 0.135
2
getgenv().Smoothness = 0.9
3
getgenv().AimPart = "UpperTorso"
4
getgenv().OldAimpart = "UpperTorso"
5
getgenv().ShakeValue = 0
6
getgenv().AutoPred = true
7
8
---// NOT MADE BY ME BUT I STILL CREDS TO LION //--
9
10
local Tool = Instance.new("Tool")
11
Tool.RequiresHandle = false
12
Tool.Name = "Lunar"
13
Tool.Parent = game.Players.LocalPlayer.Backpack
14
15
local player = game.Players.LocalPlayer
16
17
local function connectCharacterAdded()
18
player.CharacterAdded:Connect(onCharacterAdded)
19
end
20
21
connectCharacterAdded()
22
23
player.CharacterRemoving:Connect(function()
24
Tool.Parent = game.Players.LocalPlayer.Backpack
25
end)
26
27
-- Variables (Service)
28
29
local Players = game:GetService("Players")
30
local RS = game:GetService("RunService")
31
local WS = game:GetService("Workspace")
32
local GS = game:GetService("GuiService")
33
local SG = game:GetService("StarterGui")
34
35
-- Variables (regular)
36
37
local LP = Players.LocalPlayer
38
local Mouse = LP:GetMouse()
39
local Camera = WS.CurrentCamera
40
local GetGuiInset = GS.GetGuiInset
41
42
local AimlockState = true
43
local Locked
44
local Victim
45
46
local SelectedKey = getgenv().Key
47
local SelectedDisableKey = getgenv().DisableKey
48
49
-- Notification function
50
51
function Notify(tx)
52
SG:SetCore("SendNotification", {
53
Title = "Lunar Xheat",
54
Text = tx,
55
Duration = 5
56
})
57
end
58
59
-- Check if aimlock is loaded
60
61
if getgenv().Loaded == true then
62
Notify("Loaded")
63
return
64
end
65
66
getgenv().Loaded = true
67
68
-- FOV Circle
69
70
local fov = Drawing.new("Circle")
71
fov.Filled = false
72
fov.Transparency = 1
73
fov.Thickness = 1
74
fov.Color = Color3.fromRGB(255, 255, 0)
75
fov.NumSides = 1000
76
77
-- Functions
78
79
function update()
80
if getgenv().FOV == true then
81
if fov then
82
fov.Radius = getgenv().FOVSize * 2
83
fov.Visible = getgenv().ShowFOV
84
fov.Position = Vector2.new(Mouse.X, Mouse.Y + GetGuiInset(GS).Y)
85
86
return fov
87
end
88
end
89
end
90
91
function WTVP(arg)
92
return Camera:WorldToViewportPoint(arg)
93
end
94
95
function WTSP(arg)
96
return Camera.WorldToScreenPoint(Camera, arg)
97
end
98
99
function getClosest()
100
local closestPlayer
101
local shortestDistance = math.huge
102
103
for i, v in pairs(game.Players:GetPlayers()) do
104
local notKO = v.Character:WaitForChild("BodyEffects")["K.O"].Value ~= true
105
local notGrabbed = v.Character:FindFirstChild("GRABBING_COINSTRAINT") == nil
106
107
if v ~= game.Players.LocalPlayer and v.Character and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health ~= 0 and v.Character:FindFirstChild(getgenv().AimPart) and notKO and notGrabbed then
108
local pos = Camera:WorldToViewportPoint(v.Character.PrimaryPart.Position)
109
local magnitude = (Vector2.new(pos.X, pos.Y) - Vector2.new(Mouse.X, Mouse.Y)).magnitude
110
111
if (getgenv().FOV) then
112
if (fov.Radius > magnitude and magnitude < shortestDistance) then
113
closestPlayer = v
114
shortestDistance = magnitude
115
end
116
else
117
if (magnitude < shortestDistance) then
118
closestPlayer = v
119
shortestDistance = magnitude
120
end
121
end
122
end
123
end
124
return closestPlayer
125
end
126
127
-- see if key down
128
129
Tool.Activated:Connect(function()
130
if AimlockState == true then
131
Locked = not Locked
132
if Locked then
133
Victim = getClosest()
134
135
Notify("Locked onto: "..tostring(Victim.Character.Humanoid.DisplayName))
136
else
137
if Victim ~= nil then
138
Victim = nil
139
140
Notify("Unlocked!")
141
end
142
end
143
else
144
Notify("Aimlock is not enabled!")
145
end
146
end)
147
148
-- Loop update FOV and loop camera lock onto target
149
150
RS.RenderStepped:Connect(function()
151
update()
152
if AimlockState == true then
153
if Victim ~= nil then
154
local shakeOffset = Vector3.new(
155
math.random(-getgenv().ShakeValue, getgenv().ShakeValue),
156
math.random(-getgenv().ShakeValue, getgenv().ShakeValue),
157
math.random(-getgenv().ShakeValue, getgenv().ShakeValue)
158
) * 0.1
159
local LookPosition = CFrame.new(Camera.CFrame.p, Victim.Character[getgenv().AimPart].Position + (Vector3.new(Victim.Character.HumanoidRootPart.Velocity.X,Victim.Character.HumanoidRootPart.AssemblyAngularVelocity.Y*0.5,Victim.Character.HumanoidRootPart.Velocity.Z)*getgenv().Prediction))+shakeOffset
160
Camera.CFrame = Camera.CFrame:Lerp(LookPosition, getgenv().Smoothness)
161
end
162
end
163
end)
164
165
---// NOT MADE BY ME //--
166
for _, con in next, getconnections(workspace.CurrentCamera.Changed) do
167
task.wait()
168
con:Disable()
169
end
170
for _, con in next, getconnections(workspace.CurrentCamera:GetPropertyChangedSignal("CFrame")) do
171
task.wait()
172
con:Disable()
173
end
174
---// NOT MADE BY ME //--
175
176
177
178
while task.wait() do
179
if getgenv().AutoPred == true then
180
pingvalue = game:GetService("Stats").Network.ServerStatsItem["Data Ping"]:GetValueString()
181
split = string.split(pingvalue,'(')
182
ping = tonumber(split[1])
183
if ping <200 then
184
getgenv().Prediction = 0.1973432432343325
185
elseif ping < 150 then
186
getgenv().Prediction = 0.1922
187
elseif ping < 90 then
188
getgenv().Prediction = 0.16
189
elseif ping < 80 then
190
getgenv().Prediction = 0.169
191
elseif ping < 70 then
192
getgenv().Prediction = 0.1355
193
elseif ping < 50 then
194
getgenv().Prediction = 0.125
195
elseif ping < 40 then
196
getgenv().Prediction = 0.12
197
elseif ping < 30 then
198
getgenv().Prediction = 0.12
199
end
200
end
201
end