Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation not working when played on player?

Asked by 1 year ago
Edited 1 year ago

How the animation should look: How it looks on a player:

The priority on the animation is action, I don't know what could be interfering

Code on dummy (works fine when i run the game):

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://11262438869"

local a = script.Parent.Humanoid.Animator:LoadAnimation(anim)
a.Looped = true
a:Play()

Code on player in startercharacterscripts (doesn't work lol):

repeat task.wait() until script.Parent
local humanoid: Humanoid = script.Parent:WaitForChild("Humanoid")

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://11262438869"
local track = humanoid.Animator:LoadAnimation(anim)
track.Looped = true

humanoid.Running:Connect(function(s)
    if s > 0 then
        track:Play()
    else
        track:Stop()
    end
end)
0
Could you send the code? I can't really help unless there is code to test. LikeableEmmec 470 — 1y
0
LikeableEmmec, I changed my my question. There are no errors btw Kingu_Criminal 205 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

Hi, I made an animation system before. Put a script in StarterCharacterScripts. Then insert a folder in the script and rename it to Settings. In the folder place a boolvalue and a number value. Rename boolvalue to Enabled. Rename Numbervalue to Speed. Then insert animation into the script. Rename it to IdleAnimation. Make sure you go to properties tab and put your animation id into it. Here is the script:

--Variables--

local set = script.Settings

local sp = set.Speed

local enabled = set.Enabled

local hum = script.Parent:WaitForChild("Humanoid")

if hum then

    print("Success")

else

    print("No Humanoid")

end

local humanim = hum:LoadAnimation(script:FindFirstChildOfClass("Animation"))



--Playing Animation--

if enabled.Value == true then

    humanim:Play()

    humanim.Looped = true

    humanim:AdjustSpeed(sp.Value)

end 

Hope this helps and you understand. let me know if it doesn't work or you got stuck.

0
This isn't much different from my script except mine has checks for if they are running to play the animation. Kingu_Criminal 205 — 1y
0
This isn't much different from my script except mine has checks for if they are running to play the animation. I think the problem is that the normal walking animation is playing at the same time as my animation, but I don't see why since the priority Kingu_Criminal 205 — 1y
0
are u getting any errors theking66hayday 841 — 1y
0
Also what weird is that it worked for me theking66hayday 841 — 1y
Ad

Answer this question