Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)


2 comments

0

By the way, it sets the background color to like 40 thousand.

0

Did you mean to do Color3.new or do you want Color3.fromRGB?

1 answer

✓ Accepted answer

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 comment

1

You were right, i needed Color3.fromRGB..

This discussion is preserved as it was. New answers, comments, and votes are closed.