Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't my script work on a public server?

I'm now having troubles as to why this won't work in a public server. This script only works in studio and I don't really know why.

wait(.5)
id = "http://www.roblox.com/asset/?id=549955265"
Example = script.Parent.Parent
Animation = script:WaitForChild("Animation")
Animation.AnimationId = id
local animationTrack = Example.Humanoid:LoadAnimation(Animation)
animationTrack:Play()

Some of you guys might recognize this script from the last question I asked, and I did solve that problem.. however I never realized it didn't work on a public server up until now. I have FilteringEnabled on in case that makes a difference with this script. I'm using an R15 rig, but I know that's not the reason why it's not working because an R6 rig doesn't work either with this script. Every other question related to this topic all points to using FindFirstChild or WaitForChild and I'm using WaitForChild so I don't really know what to do.

2 answers

✓ Accepted answer

Ensure that this is in a localscript, as that is the only way animations can be used.

I also recommend taking a look at this blog post:

https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online

4 comments

0

I thought I wasn't supposed to use a LocalScript from the wiki. I did try that though, nothing changed.

0

Did you try reading the blog post? Also animations only work in LocalScripts.

0

Are you sure? And yes I did read the blog post. Whenever I used a localscript as you said, the script wouldn't even work when I hit "Play" instead of start sever. EDIT: I realized I forgot to tell you I'm animating an NPC, if that's why you think I shouldn't be using a localscript.

0

I figured out why it didn't work! And yes, you were right. I needed to use a localscript. Thank you!

I managed to figure out why this wasn't working! I didn't fully understand the differences between a ServerScript and a LocalScript, and all I knew was that one ran on the client's side, and one ran on the server side.

Anyway, I didn't know LocalScripts couldn't run in Workspace, so literally all I had to do was move it to StarterPack and reroute a few variables. Thank you to everyone who tried to help me!

This discussion is preserved as it was. New answers, comments, and votes are closed.