W tap sprint works but the animation dosnt

local UIS = game:GetService("UserInputService")
local lastChecked = tick()
local character = game:GetService("Players").LocalPlayer.character
local human = character:WaitForChild("Humanoid")

local Sprintanim = Instance.new("Animation")
Sprintanim.AnimationId = "rbxassetid://5969899912"
local Sprintanimtrack = human:LoadAnimation(Sprintanim)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W then
		local now = tick()
		local change = (now - lastChecked)

		if change <= 0.25 then
			human.WalkSpeed = 20
			Sprintanimtrack:Play()
		end
	end
	lastChecked = tick()
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W then
		human.WalkSpeed = 11
		Sprintanimtrack:Stop()
	end
end)
    1. when i double tap w it plays a sped up walk animation but if i press d then double tap w it auctually plays sprint
    1. when the player auctually decides to run and changes states for example jumping it resets it to the sped up walk animation

idk wat to do lol

1 Like

If this is on a group game make sure the animation is under the group name not your own.

o nah the animations are working fine its just that it sometimes plays the wrong animation https://gyazo.com/1d924d0f2e4de76cb5018f41d8da1deb

so i changed the code to

local UIS = game:GetService(“UserInputService”)
local lastChecked = tick()
local character = game:GetService(“Players”).LocalPlayer.character
local human = character:WaitForChild(“Humanoid”)

local Sprintanim = Instance.new(“Animation”)
Sprintanim.AnimationId = “rbxassetid://5969899912”
local Sprintanimtrack = human:LoadAnimation(Sprintanim)

local speed = 0

human.Running:Connect(function(currentSpeed)
speed = currentSpeed
print(currentSpeed)
end)

UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
local now = tick()
local change = (now - lastChecked)

  if change <= 0.35 then
  	if speed <= 13 then
  		Sprintanimtrack:Play()
  	end
  	human.WalkSpeed = 20
  end

end
lastChecked = tick()
end)

UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
human.WalkSpeed = 12
if speed >= 12 then
Sprintanimtrack:Stop()
end
end
end)

and i still get the same results
is there anyway to detect if a players speed is like 20 or over 20 then play animation idk wats wrong with my script

made the run animation a movement now it works :man_facepalming: