Color values not applying like intended?

So i have this skin color script that gives skin color to the player, but its not and making the values weird, no errors though, but what am i doing wrong?

players values are 1,2,3, or 4, corresponding with the color values

local GiveSkin = Instance.new("RemoteEvent",game.ReplicatedStorage)
GiveSkin.Name = "GiveSkin"

GiveSkin.OnServerEvent:Connect(function(Player, Number)
	print("skin server received")
	Player:WaitForChild("stats"):WaitForChild("SkinColor").Value = Number
	print("gave skin value to player")
end)

local bucnhOfColor = {
	[1] = {204, 142, 105},
	[2] = {255, 204, 153},
	[3] = {106, 57, 9},
	[4] = {213, 115, 61},
}

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:Connect(function(char)  
		if plr.Team ~= game.Teams.Menu then
		repeat wait() until plr:FindFirstChild("stats")
		repeat wait() until plr:FindFirstChild("stats"):FindFirstChild("SkinColor")
		repeat wait() until char:FindFirstChild("FakeLeftHand") and char:FindFirstChild("FakeRightHand")
		print("character loaded for skin giving")	
		wait()
		local val = plr:WaitForChild("stats"):WaitForChild("SkinColor").Value
		wait()
		print("got skin color value")
		if val >= 1 then
			wait()
			if val >= #bucnhOfColor then
				wait()
					char:WaitForChild("Body Colors").HeadColor3 = Color3.new(bucnhOfColor)
					char:WaitForChild("Body Colors").LeftArmColor3 = Color3.new(bucnhOfColor)
					char:WaitForChild("Body Colors").LeftLegColor3 = Color3.new(bucnhOfColor)
					char:WaitForChild("Body Colors").RightArmColor3 = Color3.new(bucnhOfColor)
					char:WaitForChild("Body Colors").RightLegColor3 = Color3.new(bucnhOfColor)
					char:WaitForChild("Body Colors").TorsoColor3 = Color3.new(bucnhOfColor)
				print("gave skin clor using #bunch")
			else
				wait()
					char:WaitForChild("Body Colors").HeadColor3 = Color3.new(bucnhOfColor[#bucnhOfColor])
					char:WaitForChild("Body Colors").LeftArmColor3 = Color3.new(bucnhOfColor[#bucnhOfColor])
					char:WaitForChild("Body Colors").LeftLegColor3 = Color3.new(bucnhOfColor[#bucnhOfColor])
					char:WaitForChild("Body Colors").RightArmColor3 = Color3.new(bucnhOfColor[#bucnhOfColor])
					char:WaitForChild("Body Colors").RightLegColor3 = Color3.new(bucnhOfColor[#bucnhOfColor])
					char:WaitForChild("Body Colors").TorsoColor3 = Color3.new(bucnhOfColor[#bucnhOfColor])
				print("gave skin clor using val")
			end
			end
		end
	end)
end)
1 Like
plr:WaitForChild("stats")
plr.stats:WaitForChild("SkinColor")
plr:WaitForChild("FakeLeftHand")
Plr:WaitForChild("FakeRightHand")

You don’t have to put wait() after every line; you’ll just be throttling the script execution.


Color3 takes 3 numbers, not a table.

local colorValue = if val > #bucnhOfColor then bucnhOfColor[#bucnhOfColor] else bucnhOfColor[val]
local color = Color3.fromRGB(colorValue[1], colorValue[2], colorValue[3]) -- use 'fromRGB', not 'new'. 'new' takes a number ranging from 0 to 1

local bodyColors = char:WaitForChild("Body Colors")
bodyColors.HeadColor3 = color
bodyColors.LeftArmColor3 = color
bodyColors.LeftLegColor3 = color
bodyColors.RightArmColor3 = color
bodyColors.RightLegColor3 = color
bodyColors.TorsoColor3 = color