when should you use client and server scripts inside a character?
there is an animate script defaulted into the player’s character as a local script however other players can still see the player’s animations
sorry if this is the wrong category
no other category fit this better
If you’re wondering, for the future, the ‘Scripting Support’ category deals with anything related to scripts or code. (or ‘Game Support’ as well)
But to answer your question, there are a few important things to note:
ServerScripts should never be placed under a player’s character: The player has full control over their character. That means that they can delete assets inside their character anytime, including server scripts. For that reason, server scripts should only go on Workspace (outside the character), or in ServerScriptService. Since those are the only secure places to execute one. Roblox patched this with the new
RejectCharacterDelitions property in
The character is… special. The character is the only animator that you can play using a local script and getting it to replicate. The reason is related with lag. When you press W in your keyboard you expect your character to move instantly, however due to server lag this isn’t possible and that leads to a delay between pressing W and moving the character. For that reason Roblox made the character fully client sided. This means that any change you do to the character will replicate to other players. Both on server or client scripts.
For this reason, the answer would be: When playing animations for the player character, a LocalScript should be used. Of course, this depends, since on some occasions (for instance, when it’s not input related) it’ll be easier to play it on the server.
Regular scripts can be put in the player’s character safely as long as you enable the new RejectCharacterDeletions property in Workspace. (It should be enabled as long as it is set to Default)
Oh, I didn’t know they added that. That’s great.
Thanks you two! This helped alot, I’ve seen many server scripts inside characters. But what happens if the characters networkowner is nil?
can local scripts still run or is it only server scripts
The client should always own its own character so you should never set the network owner to nil, but even if it was nil local scripts would still run.
For inquiries like this, I recommend consulting the FAQ section on the official Roblox website or checking out YouTube tutorials specifically focused on scripting. They would likely provide more detailed and accurate information.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.