I dont know why but when I use this script and it work this script for a run animation using r6 ive been trying for an hour and it wont work can some help me?
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local runAnimId = "rbxassetid://95424326302208" -- ✅ Your animation ID
local runSpeed = 26
local walkSpeed = 16
local humanoid = nil
local animTrack = nil
local running = false
local runAnim = Instance.new("Animation")
runAnim.AnimationId = runAnimId
-- Start running
local function startRunning()
if humanoid and not running then
running = true
humanoid.WalkSpeed = runSpeed
animTrack = humanoid:LoadAnimation(runAnim)
animTrack.Priority = Enum.AnimationPriority.Action
animTrack:Play()
end
end
-- Stop running
local function stopRunning()
if humanoid and running then
running = false
humanoid.WalkSpeed = walkSpeed
if animTrack then
animTrack:Stop()
animTrack:Destroy()
animTrack = nil
end
end
end
-- Character loaded
local function onCharacterAdded(character)
humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = walkSpeed
end
-- Connect character and input events
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then onCharacterAdded(player.Character) end
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
startRunning()
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
stopRunning()
end
end)