Hello! I have a sprinting script and I have a bug. That being that the animation only plays after changing state (jumping/falling/etc.)
I’m using the animate script for this, so it doesn’t mess up the falling and jumping animations.
script.SprintChanged.Event:connect(onRunning)
Sprint script:
local userInputService = game:GetService('UserInputService')
local humanoid = script.Parent:WaitForChild('Humanoid')
local sprinting = false
local walkAnimation = 'rbxassetid://18663805221'
local sprintAnimation = 'rbxassetid://18663803956'
local currentTrack = nil
userInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if sprinting then
sprinting = false
script.Parent.Humanoid.WalkSpeed = 16
script.Parent.Animate.walk.WalkAnim.AnimationId = walkAnimation
script.Parent.Animate.SprintChanged:Fire(humanoid.WalkSpeed)
else
sprinting = true
script.Parent.Humanoid.WalkSpeed = 24
script.Parent.Animate.walk.WalkAnim.AnimationId = sprintAnimation
script.Parent.Animate.SprintChanged:Fire(humanoid.WalkSpeed)
end
end
end)