? Полный рабочий скрипт:
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local walkAnimId = "rbxassetid://507777826" -- сюда вставь свою анимацию ходьбы
local runAnimId = "rbxassetid://507767714" -- сюда вставь свою анимацию бега
local walkTrack, runTrack
local isRunning = false
local function setupAnimations(humanoid)
local walkAnim =
Instance.new ("Animation")
walkAnim.AnimationId = walkAnimId
walkTrack = humanoid:LoadAnimation(walkAnim)
walkTrack.Priority = Enum.AnimationPriority.Movement
local runAnim =
Instance.new ("Animation")
runAnim.AnimationId = runAnimId
runTrack = humanoid:LoadAnimation(runAnim)
runTrack.Priority = Enum.AnimationPriority.Movement
end
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
setupAnimations(humanoid)
humanoid.Running:Connect(function(speed)
if speed > 0 then
if isRunning then
if not runTrack.IsPlaying then
walkTrack:Stop()
runTrack:Play()
end
else
if not walkTrack.IsPlaying then
runTrack:Stop()
walkTrack:Play()
end
end
else
walkTrack:Stop()
runTrack:Stop()
end
end)
end
local player = Players.LocalPlayer
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end
UIS.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
isRunning = true
end
end)
UIS.InputEnded:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftShift and not gameProcessed then
isRunning = false
end
end)
? Как это работает:
Когда игрок идёт — проигрывается ходьба
Когда держит Shift — активируется анимация бега
Автоматически отключается, если игрок остановился