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

Why won't this script work on multiplayer servers?

Asked by
Avectus 120
10 years ago

The code below is in a regular script, placed inside an NPC. The script works perfectly in test mode on studio but doesn't work in a multiplayer server, even if I'm the only person in the game.

The animation is one that I've made myself and is on my account.

1wait(3)
2Animation = Instance.new("Animation")
3Animation.AnimationId = "http://www.roblox.com/Asset?ID=234539352"
4animTrack = script.Parent.Humanoid:LoadAnimation(Animation)
5 
6animTrack:Play()

There are no errors on the developer panel either.

Could anyone tell me what I need to do fix this?

Thanks.

0
Also, please refrain from posting the same question repeatedly, at least until it no longer displays on the front page. adark 5487 — 10y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

As per this page of the wiki, you have to use an AnimationController object to play animations in NPCs:

1wait(3)
2local controller = Instance.new("AnimationController", script.Parent)
3 
4Animation = Instance.new("Animation")
5Animation.AnimationId = "http://www.roblox.com/Asset?ID=234539352"
6animTrack = controller:LoadAnimation(Animation)
7 
8animTrack:Play()
Ad

Answer this question