Roblox Reach Player Target (ignores players under you)

public
vxpreen Apr 02, 2024 Never 14
Clone
Lua paste1.lua 314 lines (290 loc) | 11.82 KB
1
local active = true
2
local trueActive = true
3
local reachType = "Sphere"
4
local target = "Others" -- Default target
5
local visualizerEnabled = false
6
7
local visualizer = Instance.new("Part")
8
visualizer.BrickColor = BrickColor.Blue()
9
visualizer.Transparency = 0.6
10
visualizer.Anchored = true
11
visualizer.CanCollide = false
12
visualizer.Size = Vector3.new(0.5,0.5,0.5)
13
visualizer.BottomSurface = Enum.SurfaceType.Smooth
14
visualizer.TopSurface = Enum.SurfaceType.Smooth
15
16
local ScreenGui = Instance.new("ScreenGui")
17
local Frame = Instance.new("Frame")
18
local TextLabel = Instance.new("TextLabel")
19
local TextBox = Instance.new("TextBox")
20
local TextLabel_2 = Instance.new("TextLabel")
21
local TextLabel_3 = Instance.new("TextLabel")
22
local TextLabel_4 = Instance.new("TextLabel")
23
local TextButton = Instance.new("TextButton")
24
local Frame_2 = Instance.new("Frame")
25
local Frame_3 = Instance.new("Frame")
26
local Frame_4 = Instance.new("Frame")
27
local Frame_5 = Instance.new("Frame")
28
local TextButton_2 = Instance.new("TextButton")
29
30
--Properties:
31
32
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
33
ScreenGui.DisplayOrder = 999999999
34
ScreenGui.ResetOnSpawn = false
35
36
Frame.Parent = ScreenGui
37
Frame.AnchorPoint = Vector2.new(0, 0.5)
38
Frame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
39
Frame.BackgroundTransparency = 0.300
40
Frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
41
Frame.BorderSizePixel = 4
42
Frame.Position = UDim2.new(0, 0, 0.600000024, 0)
43
Frame.Size = UDim2.new(0.150000006, 0, 0.300000012, 0)
44
45
TextLabel.Parent = Frame
46
TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
47
TextLabel.BackgroundTransparency = 1.000
48
TextLabel.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
49
TextLabel.Font = Enum.Font.SourceSans
50
TextLabel.Text = "Reach:"
51
TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
52
TextLabel.TextScaled = true
53
TextLabel.TextSize = 14.000
54
TextLabel.TextWrapped = true
55
56
TextBox.Parent = Frame
57
TextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
58
TextBox.BackgroundTransparency = 1.000
59
TextBox.Position = UDim2.new(0.600000024, 0, 0, 0)
60
TextBox.Size = UDim2.new(0.400000006, 0, 0.200000003, 0)
61
TextBox.Font = Enum.Font.SourceSans
62
TextBox.Text = "3.5"
63
TextBox.TextColor3 = Color3.fromRGB(255, 76, 76)
64
TextBox.TextScaled = true
65
TextBox.TextSize = 14.000
66
TextBox.TextWrapped = true
67
68
TextLabel_2.Parent = Frame
69
TextLabel_2.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
70
TextLabel_2.BackgroundTransparency = 1.000
71
TextLabel_2.Position = UDim2.new(0, 0, 0.200000003, 0)
72
TextLabel_2.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
73
TextLabel_2.Font = Enum.Font.SourceSans
74
TextLabel_2.Text = "Shape:"
75
TextLabel_2.TextColor3 = Color3.fromRGB(255, 255, 255)
76
TextLabel_2.TextScaled = true
77
TextLabel_2.TextSize = 14.000
78
TextLabel_2.TextWrapped = true
79
80
TextLabel_3.Parent = Frame
81
TextLabel_3.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
82
TextLabel_3.BackgroundTransparency = 1.000
83
TextLabel_3.Position = UDim2.new(0, 0, 0.400000006, 0)
84
TextLabel_3.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
85
TextLabel_3.Font = Enum.Font.SourceSans
86
TextLabel_3.Text = "Target:"
87
TextLabel_3.TextColor3 = Color3.fromRGB(255, 255, 255)
88
TextLabel_3.TextScaled = true
89
TextLabel_3.TextSize = 14.000
90
TextLabel_3.TextWrapped = true
91
92
TextLabel_4.Parent = Frame
93
TextLabel_4.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
94
TextLabel_4.BackgroundTransparency = 1.000
95
TextLabel_4.Position = UDim2.new(0, 0, 0.600000024, 0)
96
TextLabel_4.Size = UDim2.new(0.600000024, 0, 0.200000003, 0)
97
TextLabel_4.Font = Enum.Font.SourceSans
98
TextLabel_4.Text = "Visualizer:"
99
TextLabel_4.TextColor3 = Color3.fromRGB(255, 255, 255)
100
TextLabel_4.TextScaled = true
101
TextLabel_4.TextSize = 14.000
102
TextLabel_4.TextWrapped = true
103
104
TextButton.Parent = Frame
105
TextButton.AnchorPoint = Vector2.new(0, 1)
106
TextButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
107
TextButton.BackgroundTransparency = 1.000
108
TextButton.Position = UDim2.new(0, 0, 1, 0)
109
TextButton.Size = UDim2.new(1, 0, 0.150000006, 0)
110
TextButton.Font = Enum.Font.SourceSansBold
111
TextButton.Text = "Kill Script"
112
TextButton.TextColor3 = Color3.fromRGB(222, 0, 0)
113
TextButton.TextScaled = true
114
TextButton.TextSize = 14.000
115
TextButton.TextWrapped = true
116
117
Frame_2.Parent = Frame
118
Frame_2.Active = true
119
Frame_2.AnchorPoint = Vector2.new(0, 0.5)
120
Frame_2.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
121
Frame_2.BorderSizePixel = 0
122
Frame_2.Position = UDim2.new(0.725000024, 0, 0.699999988, 0)
123
Frame_2.Size = UDim2.new(0, 25, 0, 25)
124
Frame_2.ZIndex = 5
125
126
Frame_3.Parent = Frame_2
127
Frame_3.AnchorPoint = Vector2.new(0.5, 0.5)
128
Frame_3.BackgroundColor3 = Color3.fromRGB(255, 76, 76)
129
Frame_3.BorderSizePixel = 0
130
Frame_3.LayoutOrder = 1
131
Frame_3.Position = UDim2.new(0.5, 0, 0.5, 0)
132
133
Frame_4.Parent = Frame
134
Frame_4.Active = true
135
Frame_4.AnchorPoint = Vector2.new(0, 0.5)
136
Frame_4.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
137
Frame_4.BorderSizePixel = 0
138
Frame_4.Position = UDim2.new(9999999, 99999999, 9999, 999999)
139
Frame_4.Size = UDim2.new(0, 25, 0, 25)
140
Frame_4.ZIndex = 5
141
142
Frame_5.Parent = Frame_4
143
Frame_5.AnchorPoint = Vector2.new(0.5, 0.5)
144
Frame_5.BackgroundColor3 = Color3.fromRGB(255, 76, 76)
145
Frame_5.BorderSizePixel = 0
146
Frame_5.LayoutOrder = 1
147
Frame_5.Position = UDim2.new(0.5, 0, 0.5, 0)
148
Frame_5.Size = UDim2.new(1, 0, 1, 0)
149
150
TextButton_2.Parent = Frame
151
TextButton_2.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
152
TextButton_2.BackgroundTransparency = 1.000
153
TextButton_2.Position = UDim2.new(0.600000024, 0, 0.200000003, 0)
154
TextButton_2.Size = UDim2.new(0.400000006, 0, 0.200000003, 0)
155
TextButton_2.Font = Enum.Font.SourceSans
156
TextButton_2.Text = "Sphere"
157
TextButton_2.TextColor3 = Color3.fromRGB(255, 76, 76)
158
TextButton_2.TextScaled = true
159
TextButton_2.TextSize = 14.000
160
TextButton_2.TextWrapped = true
161
162
-- Add a TextBox for Target input
163
local TargetTextBox = Instance.new("TextBox")
164
TargetTextBox.Parent = Frame
165
TargetTextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
166
TargetTextBox.BackgroundTransparency = 1.000
167
TargetTextBox.Position = UDim2.new(0.600000024, 0, 0.400000006, 0)
168
TargetTextBox.Size = UDim2.new(0.400000006, 0, 0.200000003, 0)
169
TargetTextBox.Font = Enum.Font.SourceSans
170
TargetTextBox.Text = "Others" -- Default text
171
TargetTextBox.TextColor3 = Color3.fromRGB(255, 76, 76)
172
TargetTextBox.TextScaled = true
173
TargetTextBox.TextSize = 14.000
174
TargetTextBox.TextWrapped = true
175
176
-- Modify the TargetTextBox.FocusLost event to handle target selection
177
TargetTextBox.FocusLost:Connect(function(enterPressed)
178
local input = TargetTextBox.Text
179
if input:lower() == "others" then
180
target = "Others"
181
else
182
-- Check if the input matches any player's name partially or fully
183
for _, player in pairs(game.Players:GetPlayers()) do
184
if input:lower() == "others" or player.Name:lower():find(input:lower(), 1, true) then
185
target = player.Name
186
break
187
end
188
end
189
end
190
end)
191
192
-- Update the onHit function to consider the specified target and player positions relative to your character's position
193
local function onHit(hit, handle)
194
local victim = hit.Parent:FindFirstChildOfClass("Humanoid")
195
if victim then
196
if target == "Others" or (victim.Parent.Name == target and victim.Parent.Name ~= game.Players.LocalPlayer.Name) then
197
-- Get the position of your character's HumanoidRootPart
198
local hrp = game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
199
if hrp then
200
-- Check if the hit part is above your character's HumanoidRootPart
201
local hitPos = hit.Position
202
local hrpPos = hrp.Position
203
local yOffset = -0.1 -- Adjust this value as needed to avoid hitting players directly below you
204
if hitPos.Y >= hrpPos.Y + yOffset then
205
-- Interact only if the hit part is above your character
206
for _, v in pairs(hit.Parent:GetChildren()) do
207
if v:IsA("Part") then
208
firetouchinterest(v, handle, 0)
209
firetouchinterest(v, handle, 1)
210
end
211
end
212
end
213
end
214
end
215
end
216
end
217
218
repeat wait() until game.Players.LocalPlayer
219
ScreenGui.Parent = game:GetService("CoreGui")
220
221
Frame_4.InputBegan:connect(function(inp)
222
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
223
visualizerEnabled = not visualizerEnabled
224
local goal = {Size = UDim2.new(0,0,0,0)}
225
if visualizerEnabled then
226
goal = {Size = UDim2.new(1,0,1,0)}
227
end
228
game:GetService("TweenService"):Create(Frame_3,TweenInfo.new(0.12,Enum.EasingStyle.Linear),goal):Play()
229
end
230
end)
231
TextButton_2.MouseButton1Click:connect(function()
232
if reachType == "Sphere" then
233
reachType = "Line"
234
else
235
reachType = "Sphere"
236
end
237
TextButton_2.Text = reachType
238
end)
239
TextButton.MouseButton1Click:connect(function()
240
trueActive = false
241
ScreenGui:Destroy()
242
end)
243
game:GetService("UserInputService").InputBegan:connect(function(inp,gpe)
244
if gpe then return end
245
if inp.KeyCode == Enum.KeyCode.H then
246
ScreenGui.Enabled = not ScreenGui.Enabled
247
end
248
end)
249
250
local plr = game.Players.LocalPlayer
251
252
local function getWhiteList()
253
local wl = {}
254
for _,v in pairs(game.Players:GetPlayers()) do
255
if v ~= plr then
256
local char = v.Character
257
if char then
258
for _,q in pairs(char:GetChildren()) do
259
if q:IsA("Part") then
260
table.insert(wl,q)
261
end
262
end
263
end
264
end
265
end
266
return wl
267
end
268
269
game:GetService("RunService").RenderStepped:connect(function()
270
if not active or not trueActive then return end
271
local s = plr.Character and plr.Character:FindFirstChildOfClass("Tool")
272
if not s then visualizer.Parent = nil end
273
if s then
274
local handle = s:FindFirstChild("Handle") or s:FindFirstChildOfClass("Part")
275
if handle then
276
if visualizerEnabled then
277
visualizer.Parent = workspace
278
else
279
visualizer.Parent = nil
280
end
281
local reach = tonumber(TextBox.Text)
282
if reach then
283
if reachType == "Sphere" then
284
visualizer.Shape = Enum.PartType.Ball
285
visualizer.Size = Vector3.new(reach,reach,reach)
286
visualizer.CFrame = handle.CFrame
287
for _,v in pairs(game.Players:GetPlayers()) do
288
local hrp = v.Character and v.Character:FindFirstChild("HumanoidRootPart")
289
if hrp and handle then
290
local mag = (hrp.Position-handle.Position).magnitude
291
if mag <= reach then
292
onHit(hrp,handle)
293
end
294
end
295
end
296
elseif reachType == "Line" then
297
local origin = (handle.CFrame*CFrame.new(0,0,-2)).p
298
local ray = Ray.new(origin,handle.CFrame.lookVector*-reach)
299
local p,pos = workspace:FindPartOnRayWithWhitelist(ray,getWhiteList())
300
visualizer.Shape = Enum.PartType.Block
301
visualizer.Size = Vector3.new(1,0.8,reach)
302
visualizer.CFrame = handle.CFrame*CFrame.new(0,0,(reach/2)+2)
303
if p then
304
onHit(p,handle)
305
else
306
for _,v in pairs(handle:GetTouchingParts()) do
307
onHit(v,handle)
308
end
309
end
310
end
311
end
312
end
313
end
314
end)