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

I'm making a shop but when I try to purchase a skin, I get this error. Anyone know why?

Asked by 3 years ago

I keep getting this error:

Value is not a valid member of Color3

This is my code:

local purchase = Color3.fromRGB(48, 255, 117)
local equipped = Color3.fromRGB(250,170,0)
local unequip = Color3.fromRGB(255,30,30)
local UpdateButton = function()
    local selectedChar = Selected.Value
    if selectedChar then
        local name = selectedChar.Name
        if chars:FindFirstChild(name) then
            if equipped.Value == name then
                button.Text = "  UNEQUIP  "
                button.BackgroundColor3 = unequip
            else
                button.Text = "  EQUIP  "
                button.BackgroundColor3 = equipped
            end
        else
            button.Text = "  PURCHASE  "
            button.BackgroundColor3 = purchase
        end
    else
        button.Text = "  PURCHASE  "
        button.BackgroundColor3 = purchase
    end
end

1 answer

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

These lines right here define a group of colors using the Color3 class:

local purchase = Color3.fromRGB(48, 255, 117)
local equipped = Color3.fromRGB(250,170,0)
local unequip = Color3.fromRGB(255,30,30)

On line 6, you try to get the value of equipped, which in this case is a Color3 object, obtained through RGB values:

local UpdateButton = function()
    local selectedChar = Selected.Value
    if selectedChar then
        local name = selectedChar.Name
        if chars:FindFirstChild(name) then
            if equipped.Value == name then --     <-- Right here
                button.Text = "  UNEQUIP  "
                button.BackgroundColor3 = unequip
            else
                button.Text = "  EQUIP  "
                button.BackgroundColor3 = equipped
            end
        else
            button.Text = "  PURCHASE  "
            button.BackgroundColor3 = purchase
        end
    else
        button.Text = "  PURCHASE  "
        button.BackgroundColor3 = purchase
    end
end

Value is not a property of Color3. The only properties that belong to Color3 are:

number Color3.R

Returns the R (red) value from the Color's RGB value

number Color3.G

Returns the G (green) value from the Color's RGB value

number Color3.B

Returns the B (blue) value from the Color's RGB value

Note: If you defined a value earlier in your script than you defined your colors, and one (or more) of the variables you defined earlier had the same name as one of your color variables, it was effectively overridden when you defined your colors.

Ad

Answer this question