-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNi
More file actions
94 lines (77 loc) · 2.05 KB
/
Ni
File metadata and controls
94 lines (77 loc) · 2.05 KB
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
--================ Services =================
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
--================ Settings =================
local REAL_SPEED = 6.4
local VFLY_SPEED = 6.4
local CHECK_DELAY = 0.3
local MIN_TRIGGER = 19
local MAX_TRIGGER = 23
local STOP_TRIGGER = 24
--================ Vars =================
local character
local humanoid
local hrp
local vflyConn
local vflyEnabled = false
--================ VFly =================
local function startVFly()
if vflyConn then vflyConn:Disconnect() end
vflyEnabled = true
humanoid.WalkSpeed = REAL_SPEED
vflyConn = RunService.RenderStepped:Connect(function()
if not humanoid or not hrp then return end
local moveDir = humanoid.MoveDirection
local velY = hrp.AssemblyLinearVelocity.Y
if moveDir.Magnitude > 0 then
local dir = moveDir.Unit
hrp.AssemblyLinearVelocity = Vector3.new(
dir.X * VFLY_SPEED,
velY,
dir.Z * VFLY_SPEED
)
else
hrp.AssemblyLinearVelocity = Vector3.new(0, velY, 0)
end
end)
end
local function stopVFly()
if vflyConn then
vflyConn:Disconnect()
vflyConn = nil
end
vflyEnabled = false
end
--================ Main Loop =================
local function speedLoop()
task.spawn(function()
while true do
if humanoid and hrp then
local currentSpeed = humanoid.WalkSpeed
-- إذا بين 19 و 23 ➜ شغل VFly
if currentSpeed > MIN_TRIGGER and currentSpeed < MAX_TRIGGER then
startVFly()
else
stopVFly()
end
-- إذا السرعة فوق STOP_TRIGGER ➜ أوقف VFly فوراً
if currentSpeed >= STOP_TRIGGER then
stopVFly()
end
end
task.wait(CHECK_DELAY)
end
end)
end
--================ Character Setup =================
local function setupCharacter(char)
character = char
humanoid = character:WaitForChild("Humanoid")
hrp = character:WaitForChild("HumanoidRootPart")
speedLoop()
end
if player.Character then
setupCharacter(player.Character)
end
player.CharacterAdded:Connect(setupCharacter)