local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local humanoid = char:WaitForChild("Humanoid") local animator = humanoid:WaitForChild("Animator") -- ============================================================ -- ANIMATION IDs -- ============================================================ local ANIM_IDS = { Idle = "rbxassetid://114914598260626", Walk = "rbxassetid://84182114963068", Run = "rbxassetid://113934378576718", } -- ============================================================ -- LOAD ANIMATIONS -- ============================================================ local anims = {} for name, id in pairs(ANIM_IDS) do local anim = Instance.new("Animation") anim.AnimationId = id anims[name] = animator:LoadAnimation(anim) end -- ============================================================ -- HELPER: Stop all tracks except one -- ============================================================ local function stopAll(except: string?) for name, track in pairs(anims) do if name ~= except and track.IsPlaying then track:Stop() end end end -- ============================================================ -- LOCOMOTION (auto-plays on spawn) -- ============================================================ local RUN_SPEED = 16 -- studs/s threshold to switch walk -> run RunService.RenderStepped:Connect(function() local speed = humanoid.MoveDirection.Magnitude * humanoid.WalkSpeed if speed > RUN_SPEED then if not anims.Run.IsPlaying then stopAll("Run") anims.Run:Play() end elseif speed > 0.1 then if not anims.Walk.IsPlaying then stopAll("Walk") anims.Walk:Play() end else if not anims.Idle.IsPlaying then stopAll("Idle") anims.Idle:Play() end end end) -- ============================================================ -- CLEAN UP on character removal -- ============================================================ player.CharacterRemoving:Connect(function() stopAll() end)