Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to stop animation while in certain humanoidstatetype?

I want to stop this sprinting animation while I am jumping or falling but it does not seem to work. Here is code where I want it to check for the state and stop the script...

while true do
	wait()
	if Enum.HumanoidStateType.Jumping or Enum.HumanoidStateType.Freefall then
	sprintAnim:Stop()
	end
end

Not sure if this is a mistake or another piece of code in my local script is preventing it on working. Please help and explain I am new to scripting and still learning. Thanks :) Code for sprinting

-- Sprint Key Pressed
userInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		if currentStamina >= staminaCost and character.Humanoid.MoveDirection.Magnitude > 0 then
			character.Humanoid.WalkSpeed = sprintSpeed
			sprintAnim:Play()
		end
	end
end)

2 answers

✓ Accepted answer

Your sprinting is good but you're not checking the players humanoid state you're only checking humanoidstatetype which errors you!

while wait() do
	if character.Humanoid:GetState() == Enum.HumanoidStateType.Jumping or character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
		sprintAnim:Stop()
	end
end

2 comments

0

Thank you, this worked!

0

Np!

hey you! have you ever heard of enes? if you are in trouble, better call enes!

This discussion is preserved as it was. New answers, comments, and votes are closed.