Animation doesn't run

I’ve already tried to look up for other topics,like mine,but i couldn’t find the right answer.Please,can someone find an error in this local script?

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://138509202688208"
local hum = script.Parent:WaitForChild('Humanoid')
local humanoid = hum:WaitForChild("Animator")
local erm = humanoid:LoadAnimation(animation)


erm:Play()

Where did you put this local script?

i put it in startercharacterscripts

1 Like

You want it to be a local player or an NPC who plays this animation ?

1 Like

i want it to run for a local player

Did you even parent the animation instance to something???
Parent it to where you need it and then load it!

it is already parented to the script

Nope, you are constructing an instance. You never parented it.

Try this to check where is your error :

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://138509202688208"

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

local humanoid = hum:WaitForChild("Animator")
print("Animator find")

local erm = humanoid:LoadAnimation(animation)
print("Animation loaded")

erm:Play()
print("Animation played")

Here this might work:

local animation = Instance.new("Animation")
animation.Parent = script
animation.AnimationId = "rbxassetid://138509202688208"
local hum = script.Parent:WaitForChild('Humanoid')
local Animator = hum:WaitForChild("Animator")
local erm =Animator:LoadAnimation(animation)


erm:Play()

so apparently,everything prints,but the animation doesn’t work itself

I have this message :

Have you made the animation?
Did the owner share and give access?

oh that error means that u dont own the animation, did u take it from toolbox? if u did, then just reupload it as urs, this vid might help:

im working on my friend’s game,and he made the animation

local animation = Instance.new("Animation") 
local UserInputService = game:GetService("UserInputService")
animation.AnimationId = "rbxassetid://138509202688208"

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

local humanoid = hum:WaitForChild("Animator")
print("Animator find")

local erm = humanoid:LoadAnimation(animation)
print("Animation loaded")

UserInputService.InputBegan:Connect(function(Key) 
	if Key.KeyCode == Enum.KeyCode.C or Key.KeyCode == Enum.KeyCode.LeftShift then	
		erm:Play()
		print("Animation played") 
	end
end)

what about this script?

oh then uh thats not a problem if its ur friends game and his anim, in roblox it will play it just wont play for u in roblox studio

Try doing this:

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://138509202688208"
local hum = script.Parent:WaitForChild('Humanoid')
local humanoid = hum:WaitForChild("Animator")
local erm = humanoid:LoadAnimation(animation)

task.wait(0.5)
erm:Play()

I see this happen a lot, if you play an animation right when you load an animation, chances are, it wont play, so add a task.wait

Ok so this is probably why it isnt working.

In roblox you cant use other peoples animations, unless the game you are editing is under a group, and the animation was uploaded to said group, otherwise I dont believe you can use the animation

2 Likes

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