Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Im getting the error 'R Cant be assigned to'?

Asked by 3 years ago

Hello, I wanted to make a automatic rarity system that takes the stringvalue of an item, gets its rarity and then it SHOULD set the background color of the item, but it doesn't because im getting an error. The script:

local guipart = script.Parent.GuiPart
local StatsFolder = script.Parent.Stats
local rarity = StatsFolder.Rarity
local itemname = StatsFolder.ItemName

local newRarity = string.upper(rarity.Value)
local newName = string.upper(itemname.Value)

print(workspace.RarityColors.Background.COMMON.Value.R * 255, workspace.RarityColors.Background.COMMON.Value.G * 255, workspace.RarityColors.Background.COMMON.Value.B * 255)


guipart.ItemInfoGUI.Background.Rarity.Text = newRarity
guipart.ItemInfoGUI.Background.ItemName.Text = newName
guipart.ItemInfoGUI.Background.BackgroundColor3.R = Color3.new(workspace.RarityColors.Background[newRarity].Value.R * 255)
guipart.ItemInfoGUI.Background.BackgroundColor3.G = Color3.new(workspace.RarityColors.Background[newRarity].Value.G * 255)
guipart.ItemInfoGUI.Background.BackgroundColor3.B = Color3.new(workspace.RarityColors.Background[newRarity].Value.B * 255)
guipart.ItemInfoGUI.Overline.BackgroundColor3 = Color3.new(workspace.RarityColors.Overline[newRarity].Value)


0
By the way, it sets the background color to like 40 thousand. WatsPlayzROBLOX 80 — 3y
0
Did you mean to do Color3.new or do you want Color3.fromRGB? Omq_ItzJasmin 666 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

It's exactly as it says...The color value "R," or "Red," cannot be assigned to... neither can Blue nor Green. It's better to do it together, like this

guipart.ItemInfoGUI.Background.BackgroundColor3 = Color3.new(workspace.RarityColors.Background[newRarity].Value.R * 255, workspace.RarityColors.Background[newRarity].Value.G * 255, workspace.RarityColors.Background[newRarity].Value.B * 255) 

Here is the wiki for Color3 values: https://developer.roblox.com/en-us/api-reference/datatype/Color3

1
You were right, i needed Color3.fromRGB.. WatsPlayzROBLOX 80 — 3y
Ad

Answer this question