How to check if a player is moving?

How would I check if a player is moving?

hi im trying to find a solution i will be a min

1 Like

local char = character
local hum = wfc(char,“Humanoid”)
local hr = wfc(char, “HumanoidRootPart”)

hum.AutoRotate = false

local anims = {
[“Forward”] = folder.Walk_Forward.AnimationId,
[“Backward”] = folder.Walk_Backward.AnimationId,
[“Left”] = folder.Walk_Left.AnimationId,
[“Right”] = folder.Walk_Right.AnimationId,
[“Stopped”] = “Stop”
}

local anim
local track
local OldDirection

local direc = “Stopped”
key press related movement detection
local keys = {}
–//read keys to dedect direction moving
local rf = game.ReplicatedStorage.Events
rf.OnServerEvent:connect(function(p,args)
local mode = args[1]
if mode == “CharacterMovementSystem” then
keys = args[2]
direc = args[3]
end
end)

char.Humanoid.Running:connect(function(s) if s>2 then
local mov_spped = (hr.RotVelocity+hr.Velocity).magnitude
local movement_speed = char.Humanoid.WalkSpeed
if mov_spped > 5 then
local Direction = anims[direc]
local cor = coroutine.wrap(function()
if Direction ~= OldDirection and char:FindFirstChild(“Walk”) then
char.Walk:remove()
track:Stop()
end
end)
cor()
if OldDirection ~= Direction then OldDirection = Direction end
if Direction ~= “Stop” then
if char:FindFirstChild(“Walk”) == nil then
anim = Instance.new(“Animation”,char) anim.Name = “Walk”
anim.AnimationId = Direction
track = hum:LoadAnimation(anim)
track:Play()
track:AdjustSpeed(movement_speed/16)
end
else
if anim ~= nil then
track:Stop()
anim:remove()
end
end
end
end end)

this may not work but if it does thats good if not tell me

https://developer.roblox.com/en-us/api-reference/property/Humanoid/MoveDirection

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()

Character.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function(Direction: Vector3)
    -- your code right here
end)
1 Like

How would I just check if they are moving in any direction and not get the direction at all because all I need is to check if they are moving what so ever

i forgot about those features rip

humanoid.Running:Connect(function(speed)

end)
local humanoid = game.Players.LocalPlayer.Character.Humanoid
local isMoving = false

humanoid.Running:Connect(function(speed)
	if speed == 0 then
		isMoving = false
	else
		isMoving = true
	end
end)

or

local humanoid = game.Players.LocalPlayer.Character.Humanoid
local isMoving = false

humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if humanoid.MoveDirection.Magnitude == 0 then
		isMoving = false
	else
		isMoving = true
	end
end)
3 Likes