Body Colors Not Working

Hello! I am currently working on a body color randomizer.
It works, but not for other players.

When I try using a server sided script, it says Workspace.MovePart.Script:12: attempt to index nil with ‘Character’

I am placing the scripts inside StarterCharacterScripts

All feedback and help is appreciated!

A localscript is doing things local on the client, you will have to do this server side, do you want to have their body color changed when joining if yes you could simply use a event to fire whenever a player joins the game. If you just copied the localscript and placed into a script it could be that the server is looking for a localplayer that does exists(but localplayer can ony be defined in a localscript, you could also use a remote event but in my opinion the script looks like you want to let it change on join). Could you show the lines of code you tried into a script so we can look why it isn’t working?

1 Like

You can’t access localplayer on server scripts since they’re running on the server, not anyone’s client.
a solution to this is using a remote event to tell the server to change body colours.

as above its because its local if you setup in a server script like you have tried and put it in StarterCharacterScripts
use this at the top instead of your players, localplayer and character declarations

local Character = script.Parent  -- this will get the character when its added to it 
local Player = game.Players:GetPlayerFromCharacter(Character)  -- this should get the player although doesnt seem you need it in this script