rush test script roblox 2

public
vxpreen Jun 14, 2024 Never 91
Clone
1
-- loadstring(game:HttpGet("https://pastecode.dev/raw/ze1vvtgo/paste1.txt"))()
2
3
local player = game.Players.LocalPlayer
4
local userInputService = game:GetService("UserInputService")
5
local runService = game:GetService("RunService")
6
7
local toggled = false
8
9
-- Function to find the nearest target
10
local function findNearestTarget()
11
local nearestDistance = math.huge
12
local nearestTarget = nil
13
local playerPosition = player.Character and player.Character:FindFirstChild("HumanoidRootPart").Position
14
15
if not playerPosition then return end
16
17
for _, otherPlayer in ipairs(game.Players:GetPlayers()) do
18
if otherPlayer.Character and otherPlayer ~= player then
19
local humanoid = otherPlayer.Character:FindFirstChild("Humanoid")
20
local leftArm = otherPlayer.Character:FindFirstChild("Left Arm") or otherPlayer.Character:FindFirstChild("LeftUpperArm")
21
local rightArm = otherPlayer.Character:FindFirstChild("Right Arm") or otherPlayer.Character:FindFirstChild("RightUpperArm")
22
if humanoid and leftArm and humanoid.Health > 0 then
23
local targetPosition = leftArm.Position
24
local distance = (targetPosition - playerPosition).magnitude
25
if distance < 16 and distance < nearestDistance then
26
-- Check if the player is above you
27
local hrp = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
28
if hrp then
29
local hrpPos = hrp.Position
30
local yOffset = -0.1 -- below you
31
if targetPosition.Y >= hrpPos.Y + yOffset then
32
nearestDistance = distance
33
nearestTarget = otherPlayer
34
end
35
end
36
end
37
end
38
end
39
end
40
41
return nearestTarget
42
end
43
44
-- Function to move to the nearest target's left arm, avoiding the right arm
45
local function moveToNearestTarget()
46
if not toggled then return end
47
48
local target = findNearestTarget()
49
if target then
50
local leftArm = target.Character:FindFirstChild("Left Arm") or target.Character:FindFirstChild("LeftUpperArm")
51
local rightArm = target.Character:FindFirstChild("Right Arm") or target.Character:FindFirstChild("RightUpperArm")
52
if leftArm and rightArm then
53
local character = player.Character
54
local humanoid = character and character:FindFirstChild("Humanoid")
55
local humanoidRootPart = character and character:FindFirstChild("HumanoidRootPart")
56
if humanoid and humanoidRootPart then
57
-- Move to the offset position near the left arm, but stay at a safe distance
58
local offsetDirection = (leftArm.Position - rightArm.Position).unit
59
local offsetPosition = leftArm.Position + offsetDirection * 3 -- 3 studs offset from the left arm
60
61
-- Calculate a reactive position to avoid the right arm
62
local reactiveOffset = Vector3.new(math.random(-2, 2), 0, math.random(-2, 2))
63
local finalPosition = offsetPosition + reactiveOffset
64
65
humanoid:MoveTo(finalPosition)
66
67
-- Make the character look at the left arm without changing pitch and rotate slightly left
68
local lookAtPosition = Vector3.new(leftArm.Position.X, humanoidRootPart.Position.Y, leftArm.Position.Z)
69
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position, lookAtPosition) * CFrame.Angles(0, math.rad(21), 0)
70
end
71
end
72
end
73
end
74
75
-- Toggle function
76
local function toggleMovement(input)
77
if input.KeyCode == Enum.KeyCode.Q then
78
toggled = not toggled
79
end
80
end
81
82
-- Connect the toggle function to user input
83
userInputService.InputBegan:Connect(toggleMovement)
84
85
-- Connect the movement function to the RenderStepped event
86
runService.RenderStepped:Connect(moveToNearestTarget)