How can i put a animation sprint id with my script?

Hello guys ! I would like that when a person is on mobile there is a button gui which appears in its screen and when it clicks there is an animation of sprint id which launches.

here is the script

local button = script.Parent
local Player = game:GetService('Players')
local sprinting = false

local function sprint()
     local player = Player.LocalPlayer
     if sprinting then
         sprinting = false
         button.Text = 'Sprint: On'
         player.Character.Humanoid.WalkSpeed = 50
     else
        sprinting = true
        button.Text = 'Sprint: Off'
        player.Character.Humanoid.WalkSpeed = 16
     end
end

button.MouseButton1Click:Connect(sprint)
1 Like

you can create a new variable under this like this;

local Char = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")  
local SprintAnimation =  Humanoid:LoadAnimation(ANIMATION_HERE)

if sprinting then
  if SprintAnimation.IsPlaying == true then
  SprintAnimation:Stop()
  end
else
  if SprintAnimation.IsPlaying == false then
    SprintAnimation:Play()
    end

end

this should work without a problem.

2 Likes