Change BodyColor with fromRGB

Server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Events = ReplicatedStorage.Events

local function updateBodyColors(player)
	local Character = player.Character
	Character["Body Colors"].HeadColor3 = Color3.fromRGB(player.CharacterInfo.HeadColor.Value)
	Character["Body Colors"].TorsoColor3 = Color3.fromRGB(player.CharacterInfo.TorsoColor.Value)
	Character["Body Colors"].RightArmColor3 =Color3.fromRGB(player.CharacterInfo.RightArmColor.Value)
	Character["Body Colors"].LeftArmColor3 = Color3.fromRGB(player.CharacterInfo.LeftArmColor.Value)
	Character["Body Colors"].RightLegColor3 = Color3.fromRGB(player.CharacterInfo.RightLegColor.Value)
	Character["Body Colors"].LeftLegColor3 = Color3.fromRGB(player.CharacterInfo.LeftLegColor.Value)
	
	ReplicatedStorage.Events.UpdatePreview:FireClient(player)
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		task.wait(3)
		updateBodyColors(player)
	end)
end)

Events.UpdateBodyColor.OnServerEvent:Connect(function(player, bodyPart, color)
	local Character = player.Character
	player.CharacterInfo[bodyPart].Value = color
	Character["Body Colors"][bodyPart .. "3"] = Color3.fromRGB(color)
	ReplicatedStorage.Events.UpdatePreview:FireClient(player)
end)

Local script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local Events = ReplicatedStorage.Events
local container = script.Parent
local textBox = container.TextBox

textBox:GetPropertyChangedSignal("Text"):Connect(function()
	local bodyColor = textBox.Text
	local defaultColor = textBox.PlaceholderText
	
	if bodyColor ~= "" then
		Events.UpdateBodyColor:FireServer(container.Name, bodyColor)
	else
		Events.UpdateBodyColor:FireServer(container.Name, defaultColor)
	end
end)

textBox.Text = LocalPlayer.CharacterInfo[container.Name].Value


As you can see my character is just black.

No problems with the CharacterInfo values.

2 Likes

fromRGB Values acts basically the same as a Vector3 value. What you’re doing is only setting the Red value and not the Green and Blue values.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Events = ReplicatedStorage.Events

local function updateBodyColors(player)
	local Character = player.Character
	
	local bodyParts = {
		"HeadColor",
		"TorsoColor",
		"RightArmColor",
		"LeftArmColor",
		"RightLegColor",
		"LeftLegColor"
	}

	for _, part in ipairs(bodyParts) do
		local color = player.CharacterInfo[part].Value
		local colorValue = string.split(color, ",")
		Character["Body Colors"][part .."3"] = Color3.fromRGB(table.unpack(colorValue))
	end

	ReplicatedStorage.Events.UpdatePreview:FireClient(player)
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		task.wait(3)
		updateBodyColors(player)
	end)
end)

Events.UpdateBodyColor.OnServerEvent:Connect(function(player, bodyPart, color)
	local Character = player.Character
	local colorValue =  string.split(color, ",")
	
	Character["Body Colors"][bodyPart .. "3"] = Color3.fromRGB(table.unpack(colorValue))
	player.CharacterInfo[bodyPart].Value = color
	ReplicatedStorage.Events.UpdatePreview:FireClient(player)
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.