So im working on an idle position for a ball roll script here is my code
local Anims = {}
local BlacklistAnimations = {
["rbxassetid://180426354"] = true, -- Climb
["rbxassetid://754637456"] = true, -- Fall
["rbxassetid://2815169686"] = true, -- Jump
["rbxassetid://94493375873801"] = true, -- Walk / Run
["rbxassetid://2510198475"] = true, -- Swim
["rbxassetid://2510192778"] = true -- Swim Idle (optional)
}
local BoulderIdle = game.ServerStorage.BoulderIdle
local function Idle(Plr)
if Anims[Plr.Name] ~= nil then
local animTrack = Plr.Character.Humanoid:LoadAnimation(BoulderIdle)
animTrack.Priority = Enum.AnimationPriority.Core
repeat
game:GetService("RunService").Heartbeat:Wait()
if Anims[Plr.Name] == nil then
animTrack:Stop()
return
end
if Plr.Character.Humanoid.MoveDirection.magnitude <= 0.5 then
-- This is sort of broken because it runs so much it resets but we can use this if we need to and ill fix it
animTrack.Priority = Enum.AnimationPriority.Action4
animTrack:Play()
end
local OffendingAnims = 0
for i,v in pairs(Plr.Character.Humanoid.Animator:GetPlayingAnimationTracks()) do
if BlacklistAnimations[v.Animation.AnimationId] then
OffendingAnims = OffendingAnims + 1
end
end
if OffendingAnims == 0 then
if animTrack.IsPlaying == false then
animTrack:Play()
end
else
animTrack:Stop()
end
until false
end
end
Is that pose the first frame of your idle animation?
You can check to see if the animation is playing instead of playing it again over and over in your if Plr.Character.Humanoid.MoveDirection.magnitude <= 0.5 then check.
I’m not sure if this will make a difference, but why are you loading the animation every time the Idle function is called? You should be loading it into the player when they join the game and just playing it when it needs to be used.
i have 2 diff anims one for walking and 1 for walking… that lil bit of code didnt change anything besides the anim reping a bunch… i figured ide add it but it doesent change anything that happens normally in the code i just was testin and thats why i added the note there. Sorry for the confusion
Im kinda busy atm but it is running and from prints the offending anims iff plays whenever it returns to the normal pos where your just standing. The humanoid.movedirection goes off as soon as the plr stops moving (When the idle should be playing) But it still waits to go back and that (Thats why i included that clause)
Tbh with you I would rather just use a connection like Humanoid.Running and with that it will give you back the speed and just check if speed is greater than 0 to see if player is moving
something like this.
Humanoid.Running:connect(function(speed)
if speed > 0 then
Loaded["Walk"]:AdjustSpeed(speed)
if not Loaded["Walk"].IsPlaying then
Loaded["Idle"]:Stop()
Loaded["Walk"]:Play()
end
else
if not Loaded["Idle"].IsPlaying then
Loaded["Walk"]:Stop()
Loaded["Idle"]:Play()
end
end
end)
Btw I have the animation’s preloaded in a table. Also make sure your animations are the right priority like “Idle” and “Movement”