#Shift to sprint run animation

1 messages · Page 1 of 1 (latest)

graceful junco
#

my shift to sprint is working but whenever i try to add an animation it keeps bugging, as in when i stop movement but still hold shift its doing the run animation

my script :
mouse.KeyDown:connect(function (key) -- Run function
key = string.lower(key)
if string.byte(key) == 48 then
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 48 then
running = false
end
end)
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (70+(i2))
wait()
end
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 35
repeat wait () until running == false
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (80-(i
2))
wait()
end
end
end)

what run animation i want to put : 98975698395729

fossil fiber
#

you want it to detect if its walking?

graceful junco
fossil fiber
#

the animation doesnt run when shift?

graceful junco
fossil fiber
#

it keeps running even thought it's not walking?

graceful junco
barren snowBOT
#

studio** You are now Level 2! **studio

fossil fiber
#

just check if the humanoid is walking

#

to prevent it

#

from keep running

graceful junco
#

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local running = false

local RUN_ANIMATION_ID = "rbxassetid://98975698395729"
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = RUN_ANIMATION_ID

local animationTrack = nil

-- Function to get current humanoid
local function getHumanoid()
local character = player.Character or player.CharacterAdded:Wait()
return character:WaitForChild("Humanoid")
end

-- Sprint when key pressed
mouse.KeyDown:Connect(function(key)
key = string.lower(key)
if string.byte(key) == 48 and not running then -- key '0'
running = true

    local humanoid = getHumanoid()
    
    -- Load & play animation
    animationTrack = humanoid:LoadAnimation(runAnimation)
    animationTrack:Play()
    animationTrack.Looped = true

    -- Increase FOV smoothly
    for i = 1, 5 do
        game.Workspace.CurrentCamera.FieldOfView = 70 + (i * 2)
        wait()
    end

    -- Speed up
    humanoid.WalkSpeed = 35

    -- Wait for key release
    local keyConnection
    keyConnection = mouse.KeyUp:Connect(function(releasedKey)
        if string.byte(releasedKey) == 48 then
            running = false
            keyConnection:Disconnect()

            -- Reset walk speed
            humanoid.WalkSpeed = 16

            -- Reset FOV
            for i = 1, 5 do
                game.Workspace.CurrentCamera.FieldOfView = 80 - (i * 2)
                wait()
            end

            -- Stop animation
            if animationTrack then
                animationTrack:Stop()
                animationTrack = nil
            end
        end
    end)
end

end)

this is the script i use when inserting animation

graceful junco
fossil fiber
#

yes

#

because you're not checking if the player is walking or not

#

use Humanoid.MoveDirection.Magnitude to check it

graceful junco
#

ok wait

fossil fiber
#
If Humanoid.MoveDirection.Magnitude ]
> 0 then
print("Iswalking")
end
graceful junco
#

do i put that

#

directly in my script

fossil fiber
#

adjust it

graceful junco
graceful junco
#

@fossil fiber helloo

fossil fiber
#

Yes?

#

I was busy

graceful junco
#

could u help with my m1 combo though

honest kindle