Fe sonic animations script R6
Key RequiredUniversal

Fe sonic animations script R6

Universal ScriptUltikal_or_CoolkidUltikal_or_Coolkid 18.6K views 1.2K executesUpdated Feb 16, 2025
5.0/ 5(1 votes)
10100% Positive
Lua Script•117 lines (3492 chars)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local speed = 7
local runSpeed = 40
local jumpPower = 100 
local canDoubleJump = false
local doubleJumping = false

-- Animation IDs
local idleAnimId = "rbxassetid://80979207"
local walkAnimId = "rbxassetid://252557606"
local runAnimId = "rbxassetid://252557606"
local jumpAnimId = "rbxassetid://85835312"

-- Sound IDs
local footstepSoundId = "rbxassetid://80027112124187"
local jumpSoundId = "rbxassetid://1295417556"

-- Set animations
local animateScript = player.Character:WaitForChild("Animate")

animateScript.idle.Animation1.AnimationId = idleAnimId
animateScript.idle.Animation2.AnimationId = idleAnimId
animateScript.walk.WalkAnim.AnimationId = walkAnimId
animateScript.run.RunAnim.AnimationId = runAnimId
animateScript.jump.JumpAnim.AnimationId = jumpAnimId

-- Walk speed
humanoid.WalkSpeed = speed
humanoid.JumpPower = jumpPower

-- Sound
local footstepSound = Instance.new("Sound")
footstepSound.SoundId = footstepSoundId
footstepSound.Looped = true
footstepSound.Parent = character:WaitForChild("HumanoidRootPart")

-- Jump sound
local jumpSound = Instance.new("Sound")
jumpSound.SoundId = jumpSoundId
jumpSound.Parent = character:WaitForChild("HumanoidRootPart")

-- Function to update animation speed
local function updateAnimationSpeed(newSpeed)
    local speedFactor = newSpeed / runSpeed
    animator:SetSpeed(speedFactor)
end

-- Function to play footstep sound
local function playFootstepSound(speed)
    if not footstepSound.IsPlaying then
        footstepSound:Play()
    end
    footstepSound.PlaybackSpeed = speed
end

-- Function to stop footstep sound
local function stopFootstepSound()
    footstepSound:Stop()
end

-- Shift to run
local function onInputBegan(input, gameProcessed)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.LeftShift then
            humanoid.WalkSpeed = runSpeed
            updateAnimationSpeed(runSpeed)
            playFootstepSound(2) -- Set footstep speed to 2 when running
        end
    end
end

local function onInputEnded(input, gameProcessed)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.LeftShift then
            humanoid.WalkSpeed = speed
            updateAnimationSpeed(speed)
            playFootstepSound(1) -- Set footstep speed to normal when walking
        end
    end
end

UserInputService.InputBegan:Connect(onInputBegan)
UserInputService.InputEnded:Connect(onInputEnded)

-- Double jump
local function onJumpRequest()
    if canDoubleJump and not doubleJumping then
        doubleJumping = true
        humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
        jumpSound:Play()
    end
end

humanoid.StateChanged:Connect(function(_, state)
    if state == Enum.HumanoidStateType.Landed then
        canDoubleJump = false
        doubleJumping = false
    elseif state == Enum.HumanoidStateType.Freefall then
        canDoubleJump = true
    end
end)

UserInputService.JumpRequest:Connect(onJumpRequest)

-- Play footstep sound based on WalkSpeed
humanoid.Running:Connect(function(speed)
    if speed > 0 then
        playFootstepSound(1)
    else
        stopFootstepSound()
    end
end)

Features & Information

inspiration https://www.youtube.com/watch?v=_8u6riaMgss&list=PL9nSewb0Yf0cfdZWhiSd6wTk6XSKTnZUP&index=30 (DISABLE SHIFTLOCK TO USE) shift - run double jump
#sonic#roblox#universal

Community Comments (1)

Ultikal_or_CoolkidUltikal_or_CoolkidFeb 16, 2025(edited)

Remember that sometimes footsteps sound / double jump can bug sometimes to fix footsteps sound walk a bit and stop

More Scripts for Universal Scripts