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
- Using a script (I'll paste my code below)
- 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"
** You are now Level 1! **