-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovement.lua
More file actions
61 lines (48 loc) · 1.33 KB
/
movement.lua
File metadata and controls
61 lines (48 loc) · 1.33 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
local LocalEntity = require(game:GetService("ReplicatedStorage").LocalEntity)
local UIS = game:GetService("UserInputService")
local Camera = workspace.CurrentCamera
_G.Movement = _G.Movement or {
hooked = false,
Fly = false,
Noclip = false,
NoFall = false,
FlySpeed = 1.5,
NoclipSpeed = 1 / 1.25
}
if _G.Movement.hooked then
return
end
_G.Movement.hooked = true
local old
old = hookfunction(LocalEntity, function(state, env, dt)
if not state then
return old(state, env, dt)
end
local inFluid = state.inWater
or state.inLava
local mv = state.MoveDirection
if _G.Movement.NoFall and not inFluid then
state.FallDistance = nil
end
if _G.Movement.Fly then
if not inFluid then
state.FallDistance = nil
end
if mv.Magnitude > 0 then
state.Motion = mv.Unit * _G.Movement.FlySpeed
else
state.Motion = Vector3.zero
end
elseif _G.Movement.Noclip then
if not inFluid then
state.FallDistance = nil
end
if mv.Magnitude > 0 then
state.Pos += mv.Unit * _G.Movement.NoclipSpeed
end
state.Motion = Vector3.zero
end
return old(state, env, dt)
end)
local speedMul = UIS.TouchEnabled and 1.5 or 1
state.Motion = mv.Unit * _G.Movement.FlySpeed * speedMul