How do i detect wether the player is not moving or if they are moving

player.Character.LowerTorso:GetPropertyChangedSignal(‘Velocity’):Connect(function()
if player.Character.LowerTorso.Velocity < 5 then
Dirt:Destroy()
Dirt0:Destroy()
print(‘It Works I guess?’)
end
end)
I tried this, i mean i fixed it to where velocity was simplified, but it didnt work
so i just give you this version and then no matter what i do, it wont destroy the particles(Dirt and Dirt0) so if you could help with that as well

2 Likes

Use the MoveDirection property

4 Likes

i figured it out by using
char.Humanoid.Running:Connect(function(speed)
if speed > 14 then
Dirt.Parent = char.LeftFoot
Dirt0.Parent = char.RightFoot
char.Humanoid.WalkSpeed = 30
else
Dirt:Remove()
Dirt0:Remove()
print(“Player has stopped”)
end
end)
but thank you anyway

2 Likes

This won’t work for mobile when a user isn’t dragging the slider right to the end, or if the player is slow. MoveDirection is the best property to use.

3 Likes

just in case you’re not sure how to make a MoveDirection script

Code (Local Script)

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid

local VectorZero = Vector3.new(0, 0, 0)


local function Moved()		
	if Humanoid.MoveDirection ~= VectorZero then
		Humanoid.WalkSpeed = 25
	else
		print("Stopped Moving")
	end	
end

Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(Moved)
	
local function Moved()	 -- this also works
	if Humanoid.MoveDirection.magnitude > 0 then
		Humanoid.WalkSpeed = 25
	else
		print("Stopped Moving")
	end	
end

Edit: slightly improved the script

17 Likes