
KeylessUniversal

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local idleId = "rbxassetid://98946450554814"
local forwardWalkId = "rbxassetid://87493540718854"
local backwardWalkId = "rbxassetid://95970874156673"
local sprintAnimId = "rbxassetid://108891884872744"
local altIdleId = "rbxassetid://90685886162807"
local altWalkId = "rbxassetid://101924559363550"
local SPRINT_SPEED = 23
local NORMAL_SPEED = 11
local BACKWARD_SPEED = 8
local SPRINT_ANIMATION_SPEED = 3.5
local isSprinting = false
local isAltMode = false
local character
local humanoid
local rootPart
local animator
local idleTrack, forwardTrack, backwardTrack, sprintTrack
local altIdleTrack, altForwardTrack, altBackwardTrack
local heartbeatConn
local speedLoopTask
local currentTrack
local function stopTrack(track, fadeTime)
if track and track.IsPlaying then
track:Stop(fadeTime or 0.1)
end
end
local function playOnly(track, speedOverride)
if not track then return end
if currentTrack == track then
if not track.IsPlaying then
track:Play(0.1, 1, speedOverride or 1)
end
if speedOverride then
track:AdjustSpeed(speedOverride)
end
return
end
if currentTrack then
currentTrack:Stop(0.1)
end
currentTrack = track
track:Play(0.1, 1, speedOverride or 1)
if speedOverride then
track:AdjustSpeed(speedOverride)
end
end
local function makeTrack(animationId, priority, looped)
if not animationId or animationId == "" then return nil end
local anim = Instance.new("Animation")
anim.AnimationId = animationId
local track = animator:LoadAnimation(anim)
track.Priority = priority
track.Looped = looped or false
return track
end
local function cleanup()
if heartbeatConn then heartbeatConn:Disconnect() end
if speedLoopTask then speedLoopTask = nil end
for _, track in ipairs({idleTrack, forwardTrack, backwardTrack, sprintTrack, altIdleTrack, altForwardTrack, altBackwardTrack}) do
stopTrack(track, 0)
end
idleTrack = nil; forwardTrack = nil; backwardTrack = nil; sprintTrack = nil
altIdleTrack = nil; altForwardTrack = nil; altBackwardTrack = nil
currentTrack = nil
if character then
local animate = character:FindFirstChild("Animate")
if animate then animate.Enabled = true end
end
end
local function getCurrentTracks()
if isAltMode then
return altIdleTrack, altForwardTrack, altBackwardTrack or backwardTrack, nil
else
return idleTrack, forwardTrack, backwardTrack, sprintTrack
end
end
local function applyWalkSpeed()
if not humanoid or not rootPart then return end
local moveDir = humanoid.MoveDirection
local moving = moveDir.Magnitude > 0.1
if isAltMode then
humanoid.WalkSpeed = NORMAL_SPEED
return
end
if not moving then
humanoid.WalkSpeed = isSprinting and SPRINT_SPEED or NORMAL_SPEED
return
end
local dot = moveDir:Dot(rootPart.CFrame.LookVector)
if dot < -0.2 then
humanoid.WalkSpeed = BACKWARD_SPEED
elseif isSprinting then
humanoid.WalkSpeed = SPRINT_SPEED
else
humanoid.WalkSpeed = NORMAL_SPEED
end
end
local function updateAnimations()
if not humanoid or not rootPart then return end
local idleT, forwardT, backwardT, sprintT = getCurrentTracks()
local moveDir = humanoid.MoveDirection
local moving = moveDir.Magnitude > 0.1
if not moving then
playOnly(idleT)
return
end
local dot = moveDir:Dot(rootPart.CFrame.LookVector)
if dot < -0.2 then
playOnly(backwardT)
return
end
if not isAltMode and isSprinting and sprintT then
playOnly(sprintT, SPRINT_ANIMATION_SPEED)
return
end
playOnly(forwardT)
end
local function setupTracks()
if not animator then return end
idleTrack = makeTrack(idleId, Enum.AnimationPriority.Action, true)
forwardTrack = makeTrack(forwardWalkId, Enum.AnimationPriority.Action, true)
backwardTrack = makeTrack(backwardWalkId, Enum.AnimationPriority.Action, true)
sprintTrack = makeTrack(sprintAnimId, Enum.AnimationPriority.Action4, true)
altIdleTrack = makeTrack(altIdleId, Enum.AnimationPriority.Action, true)
altForwardTrack = makeTrack(altWalkId, Enum.AnimationPriority.Action, true)
altBackwardTrack = makeTrack(backwardWalkId, Enum.AnimationPriority.Action, true)
end
local function setupCharacter(char)
cleanup()
character = char
task.wait(0.2)
humanoid = character:WaitForChild("Humanoid", 5)
rootPart = character:WaitForChild("HumanoidRootPart", 5)
if not humanoid or not rootPart then return end
animator = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator")
animator.Parent = humanoid
local animate = character:FindFirstChild("Animate")
if animate then animate.Enabled = false end
setupTracks()
applyWalkSpeed()
updateAnimations()
local healthConn = humanoid.HealthChanged:Connect(function(health)
if health <= 50 then
if not isAltMode then
isAltMode = true
updateAnimations()
applyWalkSpeed()
end
end
end)
speedLoopTask = task.spawn(function()
while character and character.Parent and humanoid and humanoid.Parent do
applyWalkSpeed()
task.wait(0.1)
end
end)
heartbeatConn = RunService.Heartbeat:Connect(function()
if not character or not character.Parent then return end
if not isAltMode and isSprinting and sprintTrack and sprintTrack.IsPlaying then
sprintTrack:AdjustSpeed(SPRINT_ANIMATION_SPEED)
end
updateAnimations()
end)
task.spawn(function()
while character and character.Parent do task.wait(1) end
if healthConn then healthConn:Disconnect() end
end)
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.L then
isAltMode = not isAltMode
applyWalkSpeed()
updateAnimations()
elseif input.KeyCode == Enum.KeyCode.X then
if not isAltMode then
isSprinting = not isSprinting
applyWalkSpeed()
updateAnimations()
end
end
end)
player.CharacterAdded:Connect(setupCharacter)
player.CharacterRemoving:Connect(cleanup)
if player.Character then
task.spawn(setupCharacter, player.Character)
end



peak