local player = game.Players.LocalPlayer while not player.Character do wait() end local character = player.Character local colors = character.BodyColors if colors then colors.HeadColor = BrickColor.new(1) colors.LeftArmColor = BrickColor.new(1) colors.RightArmColor = BrickColor.new(1) colors.TorsoColor = BrickColor.new(1) colors.LeftLegColor = BrickColor.new(1) colors.RightLegColor = BrickColor.new(1) end
How would I access BodyColors? In Play Solo, it's Body Colors, not BodyColors, but I can't write down Body Colors in the script without getting this error:
18:39:50.013 - Players.Player1.PlayerGui.Characters:8: '=' expected near 'if'
One thing i noticed is that you spelled wrong... Body Colors are spaced.
local colors = character:findFirstChild("Body Colors")
and for the IF Statement, i don't notice anything wrong, but in case:
if colors ~= nil then
Full Script:
local player = game.Players.LocalPlayer while not player.Character do wait() end local character = player.Character local colors = character:findFirstChild("Body Colors") if colors ~= nil then colors.HeadColor = BrickColor.new(1) colors.LeftArmColor = BrickColor.new(1) colors.RightArmColor = BrickColor.new(1) colors.TorsoColor = BrickColor.new(1) colors.LeftLegColor = BrickColor.new(1) colors.RightLegColor = BrickColor.new(1) end
Hope this helps! Thanks, marcoantoniosantos3
Like deaththerapy said, you can use FindFirstChild
if you're not sure if the Object you are trying to access exists or not.
However, there is a method, using square brackets, to access a member with spaces in its name directly:
character["Body Colors"] -- Note that there is no period after 'character'.