#Sprint/Walk script

1 messages · Page 1 of 1 (latest)

wild saddle
#

guys I made a sprint/walk script but when it sprints in dosent switch to sprint animation anyone knows why `
local UIS = game:GetService('UserInputService')
local humanoid = script.Parent:WaitForChild('Humanoid')
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animator = humanoid:FindFirstChild("Animator")

local walk = 16
local sprint = 25

local Runanimation = script:WaitForChild("RunAnim")
local animTrack = animator:LoadAnimation(Runanimation)

local WalkAnimation = script:WaitForChild('WalkAnim')
local WalkTrack = animator:LoadAnimation(WalkAnimation)

UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = sprint
WalkTrack:Stop()
animTrack:Play()
end
end)

UIS.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = walk
animTrack:Stop()
WalkTrack:Play()
end
end)

royal egret
#

Did u make the anims r6/r15 depending on ur game?

#

Are you using ur own anims?

tawdry brook
#

You basically forcing the walk animation that roblox already got down try this

#

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local walkSpeed = 16
local sprintSpeed = 25

local runAnim = script:WaitForChild("RunAnim")
local runTrack = animator:LoadAnimation(runAnim)
runTrack.Priority = Enum.AnimationPriority.Action

UIS.InputBegan:Connect(function(input, gpe)
if gpe then return end

if input.KeyCode == Enum.KeyCode.LeftShift then
    humanoid.WalkSpeed = sprintSpeed
    if not runTrack.IsPlaying then
        runTrack:Play()
    end
end

end)

UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
humanoid.WalkSpeed = walkSpeed
runTrack:Stop()
end
end)

#

Before that change the walk and sprint animation from “movement” to “action”

#

The way you doing it is basically just forcing something on top of something that already exist

#

What you need is for your “player” to solve actions

opal thistleBOT
#

studio** You are now Level 2! **studio

tawdry brook
#

Like walk action run action sprint action