✓ Accepted answer
#What's the problem?
- Body Colors has a space in between
- LocalScripts run before the server start, therefore the script runs before the character loads
- Why would you be using a local script to change parts especially if other players will see it, if FE is on then the player's Body Colors will not be visible to other players
#What can I do?
Locate Body Colors like so: Character["Body Color"] or use :FindFirstChild() or even better: :WaitForChild().
Character["Body Color"]
Character:FindFirstChild("Body Color")
Character:WaitForChild("Body Color")
You can also stop using LocalScripts all together, because in this situation, it'll be easier to use a server Script.
#What are the Differences between Server-Sided and Client-Sided
ServerSided:
- Runs after the server is loaded
- Can affect only server-sided actions
- Can affect other players
ClientSided:
- Runs as soon as possible
- Only affects the Player
- Only runs if inside of a Descendant of
Player
#What's the Difference between the 3 ways of calling Objects through strings?
["Body Color"] is the same as calling something like so: Character.BodyColor. If it doesn't exist, the script will error and the script will stop itself there.
:FindFirstChild() is the same but will return nil if it doesn't exist and will still run the rest of the code.
:WaitForChild() is the same as above, but will Yield the script(even though it's technically a regular function) for 5 seconds and will return nil if the object doesn't exist for 5 seconds. Note it has a 2nd parameter than can change how long the function will yield.
#Final Product
game:GetService("Players").PlayerAdded:connect(function(plyr)
plyr.CharcterAdded:connect(function(char)
repeat wait() until char:FindFirstChild("Body Color")
local hulkcolor = char:FindFirstChild("Body Color")
hulkcolor.HeadColor = "Sea green"
hulkcolor.LeftArmColor = "Sea green"
hulkcolor.RightArmColor = "Sea green"
hulkcolor.RightLegColor = "Bright violet"
hulkcolor.LeftLegColor = "Bright violet"
hulkcolor.TorsoColor = "Sea green"
end)
end)
Hope it helps!
2 comments
o god the title but srsly tho this is having errors idk why
Put it in Script Form to make it easier to see