Animation wont stop when player jumps

The animation should stop when the player jumps but it wont.

Did i use JumpRequest wrong?

script.Parent.Triggered:Connect(function(plr)
	script.Parent.Enabled = false
	local humanoid = plr.Character:WaitForChild("Humanoid")
	local rootPart = plr.Character:WaitForChild("HumanoidRootPart")
	rootPart.CFrame = script.Parent.Parent.CFrame

	local anim = humanoid:LoadAnimation(script.Parent:WaitForChild("Animation"))
	anim:Play()

	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0

	local userInputService = game:GetService("UserInputService")

	userInputService.JumpRequest:Connect(function()
		anim:Stop()
		humanoid.WalkSpeed = 16
		humanoid.JumpPower = 50
	end)
end)

Instead of connecting the JumpRequest event directly, you can use the Humanoid.StateChanged event to detect when the player enters the jumping state.

Replace UserInputService.JumpRequest with Humanoid.StateChanged

1 Like

tysm i forgot about this it works now

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.