alright so i am completely new to scripting anything with strings and i got a system set up to when someone joins read a value and set the players color to that value but the issue is some of the value options wont be 11 characters long (124,92,70 something like that instead of 204, 142, 105) and when its like that it just sets the last 2 Color3 values to 0 because its trying to read the comma from it but i dont know how to filter the comma out and this is the best attempt ive had so far
Script:
local R = string.sub(Color.Value, 1, 3)
if string.match(Color.Value,",",5,7) then
local G = string.sub(Color.Value,5,6)
else
local G = string.sub(Color.Value, 5, 7)
if string.match(Color.Value,",",8) then
local B = string.sub(Color.Value,8)
else
local B = string.sub(Color.Value, 9)
end
end
for i,v in pairs(char:GetChildren()) do
if v:IsA("BodyColors") then
v.HeadColor3 = Color3.fromRGB(R,G,B)
v.LeftArmColor3 = Color3.fromRGB(R,G,B)
v.LeftLegColor3 = Color3.fromRGB(R,G,B)
v.RightArmColor3 = Color3.fromRGB(R,G,B)
v.RightLegColor3 = Color3.fromRGB(R,G,B)
v.TorsoColor3 = Color3.fromRGB(R,G,B)
end
end

1 comment
If you want to remove a comma then do string.gsub()