For scripts in StarterCharacterScripts, how do I know whether to use a Script vs. a LocalScript? For example, the following code works in a Script but not in a LocalScript:
Obviously the Roblox documentation indicated using a Script. And I’ve read a bunch of answers from searching on Google. But I still can’t tell just by looking at the code that this wouldn’t work in a LocalScript. What am I not understanding? (I’ve only been scripting Roblox for about two months now, so I’m still getting up-to-speed.)
Are you trying to detect if it has the tag from the server? Since it is a local, the changes it makes are not seen by the server and I assume that the replication of CollectionService is within that.
For a lot of things the only way to know if you can use something on client/server is by testing or looking up documentation → Roblox Creator Documentation
But the general idea is that something like game.Players.Localplayer needs the client to figure out WHO is the localplayer. I think most of the restrictions for client server are based on access to specific data or a function.
Does one error and not the other?
Does it just not function properly?
If it doesnt function properly you’re probably trying to set the tag on the client and access it on the server
Almost anything done in a local script cannot be seen by server scripts
Putting the code in a LocalScript does NOT produce any errors. It just fails to take effect and the NPC Zombies attack my character. Putting the code in a Script, however, works as expected.