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

transforming colors to their RGB?

Asked by 4 years ago
Edited 4 years ago

So I have a name gui where the color of the label should be the team color.

here's an example of what I'm trying to do

game.Players[player].Character.Head.BillboardGui.TextLabel.BackgroundColor3 = team.TeamColor

Obviously it doesnt work because teamcolor is a string (Bright Red) but the Color3 needs to be a RGB value, is there a way to transform the string color to its rgb value?

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

TeamColor is actually a BrickColor, not a string.

Luckily, BrickColor objects have a Color property, which is the RGB representation of the BrickColor!

Just append a .Color after team.TeamColor.

Also, if player is a variable that references the player object itself, don't go back to game.Players to get it – use player directly.

player.Character.Head.BillboardGui.TextLabel.BackgroundColor3 = team.TeamColor.Color

Just as a side note: use :GetService when getting services. This is the canonical way to get services. If for some reason a service is renamed, you won't be able to access it with game.ServiceName.

Ad

Answer this question