-
What do you want to achieve? Stop stamina from draining and animation from playing
-
What is the issue? Stamina drains and animation still plays even when player is standing still.
-
What solutions have you tried so far? I tried adding a check for humanoid.WalkSpeed to be less or equal to 0 but that doesn’t work. Looping breaks whole script.
UIS.InputEnded:Connect(function(key, processed)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode[Keybind] then
Run:Stop()
tween:Pause()
tween2:Play()
StaminaUsed.Value = false
end
end
end)
Is there anyways to prevent this, like Humanoid.Running?
You could try checking the humanoid’s MoveDirection
Magnitude is greater than 0 to detect walking
if humanoid.MoveDirection.Magnitude > 0 then
-- We are moving if the magnitude is greater than 0
end
Tried that and it doesn’t work.
UIS.InputEnded:Connect(function(key, processed)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode[Keybind] then
if Humanoid.MoveDirection.Magnitude < 0 then
Run:Stop()
tween:Pause()
tween2:Play()
StaminaUsed.Value = false
end
end
end
end)
Try checking if it’s equal to 0 rather than less than, I don’t think the movedirection magnitude can ever be negative
Did that too, it still drains stamina when player is holding leftshift and standing still. I tried doing a humanoid.running check but it keeps getting conflicted.
Here is how i did it.
Humanoid.Running:Connect(function()
if Humanoid.MoveDirection.Magnitude > 0 then
StaminaUsed.Value = true
else
StaminaUsed.Value = false
end
end)