Hello Developers
Im confused about this thing because I’m trying to set the Instance.new() properties using table but it doesn’t seem to work.
Table:
local Properties = {
TextLabel_TemplateProperty = {
BackgroundColor3 = Color3.fromRGB(255, 255, 255);
BackgroundTransparency = 0;
BorderColor3 = Color3.fromRGB(27, 42, 53);
BorderMode = Enum.BorderMode.Outline;
Name = "TextLabel";
Rotation = 0;
Size = UDim2.new(0, 200,0, 50);
Visible = true;
ZIndex = 1;
Font = Enum.Font.SourceSans;
RichText = false;
Text = "Label";
TextColor = Color3.fromRGB(0, 0, 0);
TextScaled = false;
TextStrokeTransparency = 1;
TextWrapped = false;
TextXAlignment = Enum.TextXAlignment.Center;
TextYAlignment = Enum.TextYAlignment.Center;
}
}
Code i used:
local NewText_ = Instance.new("TextLabel")
for Property, Value in pairs(Properties.TextLabel_TemplateProperty) do
NewText_[Property] = Value
end
Code error i got:
Players.TestAccount87000.PlayerGui.EditorUi.ServerScript:31: invalid argument #3 (BrickColor expected, got Color3)
Code i got from:
1 Like
Color3.fromrgb will be converted or divided by 255 in the table
local Test = {Color = Color3.fromRGB(10, 10, 10)} -- This will be converted into
0.0392157, 0.0392157, 0.0392157 -- this
1 Like
Where do you set a BrickColor? I don’t understand what line is the issue.
BrickColors should be set with BrickColor.new() and Color3s should be set with Color3.new()
1 Like
Well i fixed it because of
TextColor = Color3.fromRGB(0, 0, 0);
must be
TextColor3 = Color3.fromRGB(0, 0, 0);
but thanks btw
Rinpix
(Rinpix)
January 2, 2022, 12:29pm
5
You typed TextColor, which caused the script to expect a BrickColor; you need to type TextColor3 instead.
1 Like
There’s no brickcolors actually, i just typo in TextColor making me have a error. (Ye i should’ve double checked)
But you’ll need to multiple R, G and B by 255 or it wont work – only if you save it
1 Like
Not true. Color3.fromRGB() handles dividing by 255
1 Like
It’ll be divided by 255 inside of the table and Color.fromRGB doesn’t convert it back to the original color but apparently a ui object does automatically convert it
If inside the table, it is converted from RGB to Color3, and set the color, it will be setting it normally. No manipulation needed.
So you’d do
local Table = {Color = Color3.fromRGB(125, 125, 125)
print(Color3.new(Table.Color)) ??
No. if you set Table = {Color = Color3.fromRGB(125, 125, 125), to access the Color3 Value all you would need to type is print(Table.Color)
That would return the Color3 version, which is RGB/255
Oh I know that but to convert it back into an RGB value you’ll need to multiply it by 255. I misunderstood you.
1 Like