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

Problem with Color3.new any workarounds/fixes?

Asked by
CHATED 10
10 years ago

I'm trying to use RGB Color with Color3.new but it won't change the color to the rgb number I put in. I tried other methods but didn't work

local debounce = false
local button = script.Parent
script.Parent.MouseButton1Click:connect(function()
    if debounce == false then
        button.BackgroundColor3 = Color3.new(101,  181,  50)
        button.Text = "No"
        debounce = true
    elseif debounce == true then
        button.BackgroundColor3 = Color3.new(170,  68,  68)
        button.Text = "Yes"
        debounce = false
    end
end)

2 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Your problem is that Color3.new() only takes a number between 0 and 1. If you want it between 0 and 255, like most people do, you have to divide it by 255 to again get a number between 0 and 1.

local debounce = false
local button = script.Parent
script.Parent.MouseButton1Click:connect(function()
    if debounce == false then
        button.BackgroundColor3 = Color3.new(101/255,  181/255,  50/255)
        button.Text = "No"
        debounce = true
    elseif debounce == true then
        button.BackgroundColor3 = Color3.new(170/255,  68/255,  68/255)
        button.Text = "Yes"
        debounce = false
    end
end)

Ad
Log in to vote
-1
Answered by 10 years ago

I think it needs to wait because it does loop without waiting and crashes. I don't know I just think.

0
I mean it wont display an rgb color CHATED 10 — 10y
0
Write every movement on paper that should help. vincius0000 0 — 10y

Answer this question