Hello!
I can’t seem to get the “BodyColors” Instance from the character…
Function
local Player = Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local function GetSkinColor(Character) --22
local BodyColors = Character:FindFirstChildOfClass("BodyColors") --23
local RightArmColor = BodyColors.RightArmColor3 --24
local LeftArmColor = BodyColors.LeftArmColor3 --25
return RightArmColor, LeftArmColor --26
end --27
Error
Players.fakedantdm1000.PlayerScripts.CreateViewport:24: attempt to index nil with 'RightArmColor3'
Tried
local BodyColors = Character["Body Colors"] --23
local BodyColors = Character:WaitForChild("Body Colors") --23
local BodyColors = Character:FindFirstChild("Body Colors") --23
This is probably a really stupid issue but I can’t find any way to solve it.
2 Likes
I think this issue is about defining the BodyColors
Instance Itself

Oh I see the issue
You’re not detecting if there’s either a Character
being added, or a Character
Instance already added to the game before the script even started
Try this:
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Try this?
local function GetSkinColor(Character) --22
local BodyColors = Character:FindFirstChild("BodyColors") --23
print(BodyColors)
if BodyColors then
print(BodyColors.ClassName)
local RightArmColor = BodyColors.RightArmColor3 --24
local LeftArmColor = BodyColors.LeftArmColor3 --25
return RightArmColor, LeftArmColor --26
end
end --27
The issue is the defining of “Body Colors” Then:

Your Character
parameter may be nil
if that’s the case, can you check that what you’re passing is valid to your local function?
Added Character Print:
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
-- ...
local function GetSkinColor(Character)
print(Character) -- "fakedantdm1000" (My Username)
local BodyColors = Character:FindFirstChild("BodyColors")
print(BodyColors) -- nil
-- ...
Output:

So the Character
Model is valid then
Try looping through all of the Character’s Children, and see if you can find anything that’s relevant to a BodyColors
object of some sort
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
-- ...
local function GetSkinColor(Character)
print(Character) -- "fakedantdm1000" (My Username)
for _, Object in pairs(Character:GetChildren()) do
print(Object)
end
--local BodyColors = Character:FindFirstChild("BodyColors")
--print(BodyColors) -- nil
I’m so confused:
local function GetSkinColor(Character) --22
print(Character) -- "fakedantdm1000" (My Username)
for _, Object in pairs(Character:GetChildren()) do
print(Object)
end
print(Character:FindFirstChild("Health"))
local BodyColors = Character:FindFirstChild("BodyColors") --23
print(BodyColors)
if BodyColors then
print(BodyColors.ClassName)
local RightArmColor = BodyColors.RightArmColor3 --24
local LeftArmColor = BodyColors.LeftArmColor3 --25
return RightArmColor, LeftArmColor --26
end
end --27

Are you passing a Character property of some sort
You should just be passing the Character Model as its own
I am.
I’ve created another game and copied the required scripts into it:
ScriptingSupport(8).rbxl (27.8 KB)
I’m so confused to why this is happening.
Ok so looking at the code, all I had to do was change this
To this
local BodyColors = Character:WaitForChild("Body Colors")
And I referenced the loop after defining the BodyColors
variable, and that pretty much worked
local function GetSkinColor(Character) --22
print(Character) -- "fakedantdm1000" (My Username)
local BodyColors = Character:WaitForChild("Body Colors") --23
for _, Object in pairs(Character:GetChildren()) do
print(Object)
end
print(BodyColors)
if BodyColors then
print(BodyColors.ClassName)
local RightArmColor = BodyColors.RightArmColor3 --24
local LeftArmColor = BodyColors.LeftArmColor3 --25
return RightArmColor, LeftArmColor --26
end
end --27