#Help with loading Walk and Run Animations

1 messages · Page 1 of 1 (latest)

atomic shuttle
#

Heya, new to roblox (but not programming) here. I'm trying to load a walk and run animation for my r6 player rig, but literally nothing is working and it's kind of driving me crazy. For more context, I set up a shift to sprint script which works flawlessly, it just changes my walkspeed. Now I'm trying to add animations for both my default walk, and when i sprint, but nothing is working and i have no idea why.

Details:

  • I have an r6 rig and r6 animations (and i know they work). To be specific i force my player to use that r6 avatar i've set
  • I've tried two ways
  1. Using a script (I'll paste my code below)
  2. Using the local animate script in the player

the 2nd way works only for my walk animation, but not my run animation script, even after changing some values in the actual animate script for whatever god forsaken reason.

Here's my script code

 
local Humanoid: Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local RunService: RunService = game:GetService("RunService")
local Animations = game:GetService("ReplicatedStorage").PlayerAnimations
local Animator: Animator = Humanoid:WaitForChild("Animator") --Ignore error, weird behaviour but should be functional

local walkTrack = Animator:LoadAnimation(Animations.Walk)
local sprintTrack = Animator:LoadAnimation(Animations.Sprint)

walkTrack.Priority = Enum.AnimationPriority.Movement
sprintTrack.Priority = Enum.AnimationPriority.Movement

walkTrack:Play(0, 1)
sprintTrack:Play(0, 0)

local isSprinting = false
local walkSpeedDefault = 16

function checkForSprint(speed: number)
    return speed > walkSpeedDefault
end

RunService.RenderStepped:Connect(function()
    local speed = Humanoid.WalkSpeed
    
    isSprinting = checkForSprint(speed)

    if isSprinting then
        walkTrack:AdjustWeight(0, 0.5)
        sprintTrack:AdjustWeight(1, 0.5)
    else
        sprintTrack:AdjustWeight(0, 0.5)
        walkTrack:AdjustWeight(1, 0.5)
    end
end)```

And here's the code I changed in the animate script (copied and pasted from the forum, but from my understanding fits my specs)

```lua

function onRunning(speed)
    speed /= getRigScale()
    
    if speed > 16 then
        playAnimation("run", 0.1, Humanoid)
        pose = "Running"
    elseif speed <= 16 and speed > 0.01 then
        playAnimation("walk", 0.1, Humanoid)
        if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=180426354" then
            setAnimationSpeed(speed / 14.5)
        end
        pose = "Walking"
    else
        if emoteNames[currentAnim] == nil then
            playAnimation("idle", 0.1, Humanoid)
            pose = "Standing"
        end
    end
end ```

Just to be clear, I tried both ways, not both of them simulatenously, in case that was a point of confusion. Any and every help would be greatly appreciated. I've also watched every video known to mankind and every post on the forums known to mankind, I just can't get it to work. 

Also, if it matters (I don't think it does), I'm using rojo with vscode. I mentioned it because there is a setting i can't access if i don't publish, which i can't because im constantly overwriting my place file.

SOLVED: Just had to rename my custom script into "Animate"
fringe pike
atomic shuttle
fringe pike
atomic shuttle
fringe pike
#

Or

#

let me think

#

What about the priority?

#

The animation priority

atomic shuttle
#

the first script i sent is bascially my custom animate script but only for walking and sprinting, and the second one i my modified animate script

atomic shuttle
fringe pike
atomic shuttle
south stirrupBOT
#

studio** You are now Level 1! **studio

fringe pike
#

or what is the problem with the first script?It seems fine

atomic shuttle
atomic shuttle
atomic shuttle
fringe pike
#

One more question: while using the first script, the idle animations dont exist no?

fringe pike
atomic shuttle
fringe pike
fringe pike
#

You are checking if the walkspeed is more than 0 I think

#

You need to check if the speed is bigger than the running speed

#

not the walkspeed

#

Walkspeed doesnt change if you are standing still

#

nor when you walk

#

May that be the bug?

#

or not really because else you would be playing the animation while standing still

atomic shuttle
fringe pike
#

hmmmm

#

stop the idle animations while moving?

atomic shuttle
fringe pike
#

and you can also delete the default Animate script and paste yours, but be sure its named "Animate"

atomic shuttle
fringe pike
atomic shuttle
atomic shuttle
fringe pike
#

and also check if the default Animate is still there

atomic shuttle
#

OMG IT WORKS, HOLY BALLS, ARE YOU KIDDING ME

#

still a bug, it's playing the animation while im idle, but i can fix that

#

holy crap i can't thank you enough, i can't believe it 😭

fringe pike
atomic shuttle
fringe pike
fringe pike
atomic shuttle
fringe pike