Play Random Animation Problem

So I have this NPC and want to make it do several animations, but it seems that its not doing it. This is my script:

local dummy = workspace:WaitForChild("Dummy")
dummy.Name = game.Players.LocalPlayer.Name
local humanoid = dummy.Humanoid:Clone()
dummy.Humanoid:Destroy()
humanoid.Parent = dummy
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(game.Players.LocalPlayer.UserId))
local controller = game.Workspace[game.Players.LocalPlayer.Name].Humanoid
local AnimCall = Instance.new("Animation")

local randomVars = {"http://www.roblox.com/asset/?id=3337994105", "http://www.roblox.com/asset/?id=5938365243", "http://www.roblox.com/asset/?id=5938394742"} -- put the variables in a table

while true do
	local randomVar = randomVars[math.random(#randomVars)] -- picking a random variable from the table
	print(randomVar)
	AnimCall.AnimationId = randomVar
	local Call = controller:LoadAnimation(AnimCall)
	Call:Play()
	wait(10)
	
end

This is a LocalScript inside StarterCharacterScripts
Hope someone know how to fix this, Thanks!

You might want to replace those with rbxassetid://"youridhere".
You could also try switching the LocalScript’s parent to the player’s Backpack or PlayerScripts.

Ah okay, let me try that rq. Thanks!

Oh yea, i forgot to tell you that the animation is working, but only 1 animation is playing everytime, I want it to be like the first time it play a, next play c then a then b like that, but now, it just keep playing a all the time

You could use AnimationTrack.Stopped to detect whenever the animation is done playing and re-play it under a new AnimationId.

https://developer.roblox.com/en-us/api-reference/event/AnimationTrack/Stopped

so it will be like,

while true do
repeat wait() until animationtrack.stopped

then choose another animation?

No, you could simply use AnimationTrack.Stopped:Wait().

while true do
	local randomVar = randomVars[math.random(#randomVars)] -- picking a random variable from the table
	print(randomVar)
	AnimCall.AnimationId = randomVar
	local Call = controller:LoadAnimation(AnimCall)
	Call:Play()
    Call.Stopped:Wait()
    Call:Stop()
end

Ok, let me try this real quick!

I just noticed after watching the script again, what are you trying to do on the first lines of your script?

local dummy = workspace:WaitForChild("Dummy")
dummy.Name = game.Players.LocalPlayer.Name
local humanoid = dummy.Humanoid:Clone()
dummy.Humanoid:Destroy()
humanoid.Parent = dummy
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(game.Players.LocalPlayer.UserId))
local controller = game.Workspace[game.Players.LocalPlayer.Name].Humanoid

It makes the npc’s avatar to player’s avatar

And I just noticed 1 thing, the animation played on the server side, but not on the client side
image
Static
image
Animation Playing

That’s weird, the animation is not playing on your client but plays on the server?

Exactly, I dont know whats wrong, let me revert it to the first version

If u want to know the working script for both client and server side, here it is:

local dummy = workspace:WaitForChild("Dummy")
dummy.Name = game.Players.LocalPlayer.Name
local humanoid = dummy.Humanoid:Clone()
dummy.Humanoid:Destroy()
humanoid.Parent = dummy
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(game.Players.LocalPlayer.UserId))
local controller = game.Workspace[game.Players.LocalPlayer.Name].Humanoid
local AnimCall = Instance.new("Animation")
AnimCall.AnimationId = "http://www.roblox.com/asset/?id=3337994105"
local Call = controller:LoadAnimation(AnimCall)

Call:Play()
Call.Looped = true

*Only with 1 animation ID

Weird. I rewrote it to make it clearer. Also, if you want this to be visible by every players, you might want to transfer this into a Server Script, with some modifications.

local dummy = workspace:WaitForChild("Dummy")
local humanoid = dummy:WaitForChild("Humanoid")
humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(game.Players.LocalPlayer.UserId))
local animation = Instance.new("Animation", dummy)

local animations = {
"http://www.roblox.com/asset/?id=3337994105",
"http://www.roblox.com/asset/?id=5938365243",
"http://www.roblox.com/asset/?id=5938394742"
}

while true do
	local randomVar = animations[math.random(1, #animations)]
	animation.AnimationId = randomVar
	local animationTrack = humanoid:LoadAnimation(animation)
	animationTrack:Play()
	animationTrack.Stopped:Wait()
    animationTrack:Stop()
end

Isnt the randomVars should be Animations instead?

Oh my bad, yeah I forgot to change the variable.

Only 1 animation is playing, that is the godlika animation. One more thing:
image

Oh yeah, ApplyDescription is a function that can only be called on the server. You might just want to switch to a server script.

But then the avatar can only be 1 right? I mean, for example you have 2 player, a and b
for a, it shows his avatar, and for b it also shows a’s avatar right?
Because its a server script