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

Issue with BackgroundColor3 from GUI (?)

Asked by 6 years ago

Hi guys,

I've got a module script inside a GUI which is supposed to returning a Color3 value from the background colour of the GUI:

local _M = {}

function _M.colour(p_colour)
    local ref = script.Parent
    p_colour = Color3.fromRGB(ref.BackgroundColor3.r, ref.BackgroundColor3.g, ref.BackgroundColor3.b)
    print(p_colour)
    return(p_colour)
end

return _M

the background of the GUI is: 50, 142, 184

but It always returns: 00768935, 0.00218378, 0.00282968

...which is clearly wrong.

I've also tried:

local _M = {}

function _M.colour(p_colour)
    local ref = script.Parent
    p_colour = Color3.fromRGB(ref.BackgroundColour3)
    print(p_colour)
    return(p_colour)
end

return _M

But this returns 0,0,0 black again...

Why is this happening and how can I fix it?

Thank you for your time! :) Sorry if this is a dumb question haha

0
Try just Color3.new() rather than Color3.fromRGB(). KingLoneCat 2642 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local _M = {}

function _M.colour(p_colour)
    local ref = script.Parent
    p_colour = ref.BackgroundColour3 -- Removed Color3.fromRGB
    print(p_colour)
    return(p_colour)
end

return _M
Ad

Answer this question