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

Issue with BackgroundColor3 from GUI (?)

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

1 comment

0

Try just Color3.new() rather than Color3.fromRGB().

1 answer

✓ Accepted answer
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

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