How do I detect when a player has stopped moving

As seen in this picture, I am trying to make it print “player has stopped” when the local player stops moving. There are no errors, however it is not printing it.

Is there a more efficient way of doing this?
Is there any errors I made?

2 Likes

That’s pretty easy!

local Player = game.Players.LocalPlayer;

local Character = Player.Character or Player.CharacterAdded:Wait();
local RunService = game:GetService("RunService");


RunService.RenderStepped:Connect(function()
   local Humanoid = Character:FindFirstChild("Humanoid");
   if Humanoid then
        if Humanoid.MoveDirection.Magnitude == 0 then
             print("The player has stopped moving!")
         end
     end
end)

Hope this helped!

11 Likes

MoveDirection has a property called “Magnitude”. Just check if Magnitude == 0

This worked! Thank you! Appreciate it!

I am glad this helped you!:smiley:

1 Like