Whats the best form to detect if the player is moving with animation.
So im making a running system.
- Issues:
- Animation countines plays when i use move direction to zero.
I have tried see the movement of all axis.
Any Help Is appreciate😉
Whats the best form to detect if the player is moving with animation.
So im making a running system.
I have tried see the movement of all axis.
Any Help Is appreciate😉
im new to here so how i do that btw?
--(hum = humanoid object)
if hum.MoveDirection.Magnitude < 0.05 then
youranimation:Stop(fadeOutTime)
end
Not sure if this is exactly correct (The AnimationTrack:Stop()) arguments aren’t fresh in my head right now).
You could probably modify 0.05 if you wanted because you might want to only stop it at an extremely low speed. You should also check Humanoid:GetState()
and make the animation stop if the player is mid-air.
I tried that but it didnt work
Some other issue with your code must be arising then; could you show me your code? You should always provide code so other people trying to help you can quickly point out your issue.
sure here
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://12957118599"
local keybind = Enum.KeyCode.LeftShift
local running = false
local playnow
UIS.InputBegan:Connect(function(input: InputObject,gameprocessed: boolean)
if gameprocessed then return end
if input.KeyCode == keybind then
if humanoid.MoveDirection.Magnitude > 0 then
character.Humanoid.WalkSpeed = 28
for i = 1,5 do
workspace.CurrentCamera.FieldOfView = (75+(i*2))
end
if player.Character ~= nil then
playnow = character.Humanoid.Animator:LoadAnimation(animation)
print(animation.Parent)
playnow:Play()
running = true
end
end
end
end)
function End(input: InputObject,gameprocessed: boolean)
if gameprocessed then return end
if input.KeyCode == keybind then
playnow:Stop()
character.Humanoid.WalkSpeed = 16
workspace.CurrentCamera.FieldOfView = 70
running = false
end
end
UIS.InputEnded:Connect(End)
humanoid.StateChanged:Connect(function(state)
if running then
if state == Enum.HumanoidStateType.Jumping then
playnow:Stop()
character.Humanoid.WalkSpeed = 28
elseif state == Enum.HumanoidStateType.Landed or state == Enum.HumanoidStateType.Running then
playnow:Play()
character.Humanoid.WalkSpeed = 28
end
end
end)
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if running then
if character.Humanoid.MoveDirection == 0 then
playnow:Stop()
end
end
end)
You didn’t do exactly that. I’m pretty sure the MoveDirection is a tiny decimal unless I’m mistaken (most likely I am).
i did that and also not working here
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if running then
if character.Humanoid.MoveDirection <= 0.05 then
playnow:Stop()
end
end
end)
it shows error that is
oops my bad
I meant MoveDirection.Magnitude. Sorry
thanks it worked but theres is a bug that when u press again it didnt work
What specific thing doesn’t work? The animation?
If u press the w key again that doesnt work