The animation script won´t work

my animation script won´t work, idk why there was also an error here:

local player = game.Players.LocalPlayer

local animid = "rbxassetid://11355266681 "

local newanim = Instance.new("Animation")

newanim.Parent = player

newanim.AnimationId = animid

local playanim = player.Character.Humanoid:LoadAnimator(newanim)

while wait(1) do
	
playanim:play()
end

any feedback tysm!

What’s the error? Perhaps it’s an animation ownership issue?

  1. Maybe try using Humanoid.Animator:LoadAnimation()

  2. Maybe the character doesn’t exist yet are you’re attempting to do Player.Character in replacement try:

local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()

  1. Try having a pre-created Animation inside the script so you can do:

Humanoid.Animator:LoadAnimation(script.Animation)

  1. Make sure you own the animation

  2. Make sure you’re doing it on the client

1 Like

You need to do a WaitForChild for everything when loading things from Client side.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local playanim = animator:LoadAnimation(newanim)

1 Like

u used that and my script but din´t work here;

local animid = "rbxassetid://11355266681 "

local newanim = Instance.new("Animation")


newanim.AnimationId = animid

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local playanim = animator:LoadAnimation(newanim)

while wait(1) do

	playanim:play()
end


there was no error,hmm

It’s working for me. In the script you just updated, you didn’t parent the newanim

If it’s not working then it’s the animation. Did you make it? Is it own by Roblox? If it’s not own by you or Roblox, it might not work if somebody else made it. If it’s a group game, you have to Publish to Roblox under the group’s name, not your name.

If it is still not working but code gives no errors then maybe you exported your animation with a priority of “Idle”

-- all code above...

local playanim = animator:LoadAnimation(newanim)
playanim.Priority = Enum.AnimationPriority.Action

while wait(1) do
	playanim:Play()
end
2 Likes

There is no need to parent animation instances in order to play them or load them into an animator, actually you could just delete the Animation instance after loading it to the animator and as long as you store the AnimationTrack you would still be able to play it.

1 Like

Good to know. Thanks for sharing that.

1 Like

sorry, i made a mistake its owned by a group

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.