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

Why won't this gui background color take from the color3value inside the player?

Hello, I have a problem with a local script inside a gui, everything exists. The problem is the backgroundcolor3 won't show up on the gui. Please help, thanks.

Heres the script:

if game.Workspace.Map.Type.Value == "ColorBricks" then
for i, v in pairs (game.Players:GetPlayers()) do
v.PlayerGui.PlayerScreenGui.BackgroundFrame.ColorNoticeFrame.ColorLabel.BackgroundColor3 = v.Character.Color.Value
end
end

and I've tried this:

if game.Workspace.Map.Type.Value == "ColorBricks" then
for i, v in pairs (game.Players:GetPlayers()) do
v.PlayerGui.PlayerScreenGui.BackgroundFrame.ColorNoticeFrame.ColorLabel.BackgroundColor3 = Color3.new(v.Character.Color.Value)
end
end

1 comment

0

I got it now thanks.

1 answer

✓ Accepted answer

Well, the problem is line 3-ish(?): you're trying to get a colour from the player's character itself, which is a model, and with a model, it doesn't come with a colour for itself. XP

However, depending if a player is using a R6 or R15, you can directly get the Colour(3) from the player's Torso or Upper... Lower... HumanoidRootPart... Idk. ;-; But, anyways, you can get the colour from the whatever the dang R15 objects are...

To be more specific about what I mean, you could get the colour using a fun(ny) little bit of code, rarely known of by the name of .Color. ...Yes, it's that simple, but ROBLOX doesn't wanna make it that simple for new players! :D Ok, back on topic, you can retrieve the Colour(3) of an object (or part) by using this neat trick. ;P (Click here for an example of this, or read the following code)

An example of this would be:

-- Note: Certain objects are not defined, and nothing in here will be explained; pretty self-explanatory if you've been scripting for a while; however, if need be, I'll explain the things that don't quite make sense. :)

local PlayersTorso = Character:FindFirstChild('Torso') or Character:WaitForChild('UpperTorso')
-- /\ I hate to have to do this. ;/
local ColourToGUI = PlayersTorso.Color
-- Defines the player's torso colour.

GUI.BackgroundColor3 = ColourToGUI
-- Sets the GUI's Background colour to the colour of the torso; if you test this in game, you'll see this in action. ;P

And that's pretty much it. lol There's not much more to talk about, but I would like to add that you can do this vise-versa: you can set the player's Torso/ other object colour to a GUI's background colour too! :O (Click here for an example/ a better explanation on this/ if it's too awesome to believe!!! :O )

Hope this helped you in any way! :D

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