#could i get some help with my sprint system? i just want the animation it plays to be activated

1 messages · Page 1 of 1 (latest)

stone minnow
#

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 35 --run speed
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://18140917282'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16 --default walk speed
PlayAnim:Stop()
end
end)

tranquil geode
#

Uhm

#

Load animation with the animator inside of humanoid

stone minnow
sacred junco
#

A much simpler way to go about this would be:

Before everything, load both walk and run animations to the animator. You should now have two AnimationTracks

Listen to humanoid's Running event with parameter speed: If speed >= 35, stop walk animTrack, play run animTrack. Else, vice versa.