Sprint script problem/bug?

  1. What do you want to achieve? Keep it simple and clear!

So basically. Im trying to make a sprinting system for my game

  1. What is the issue? Include screenshots / videos if possible!

The problem is that. The sprint animation works prefectly. But when you jump it stops and starts playing the walk animation for some reason while still running

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have been looking at some youtube tutorials and a bit on on the “Scripting helpers” site. But cant find anything useful?

Heres a short video showing what i mean:

As you can see. The jumping animation is also ahving some problems… The run, walk and jump animations prorities are set to “action” by the way.

Heres my code im currently using at the moment:

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local Running = false



UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.LeftShift then
		if Running == false then
			Running = true
			local ANIM = Player.Character.Humanoid:LoadAnimation(script:WaitForChild("RUN", 4))
			Player.Character.Humanoid.WalkSpeed = 50
			game.TweenService:Create(game.Workspace.CurrentCamera, TweenInfo.new(0.1), {FieldOfView = 90}):Play()
			ANIM:Play()
			repeat wait() until Running == false
			ANIM:Stop()
		end
	end
end)


UIS.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.LeftShift then
		Running = false
		Player.Character.Humanoid.WalkSpeed = 16
		game.TweenService:Create(game.Workspace.CurrentCamera, TweenInfo.new(0.1), {FieldOfView = 70}):Play()
	end
end)
1 Like

Could it possibly be that when the humanoid is on the falling state, it defaults back to the walking animation? The other possibility is just an issue with animation weights and the hold-up.

2 Likes