I’m simply just trying to set text color based on TeamColor
I’ve tried doing newMsg.Text.TextColor3 = BrickColor.new(color) [color returns White and newMsg is a clone of a textbox]
Let me know if this is possible.
I’m simply just trying to set text color based on TeamColor
I’ve tried doing newMsg.Text.TextColor3 = BrickColor.new(color) [color returns White and newMsg is a clone of a textbox]
Let me know if this is possible.
Brickcolor.new(blahblah).Color
script.Parent.TextColor3 = TeamColor.Color
From what I can tell, the issue is that Team instances use Roblox’s pre-chosen Colors, meanwhile TextColor3 uses Color3.
Considering how Roblox’s pre-chosen colors also show their actual RGB values in instances such as parts, I guess you can just grab the RGB values by putting a part with a matching BrickColor, and then just paste in the values:
if Player.Team.Name == "Red" then
TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
else
TextLabel.TextColor3 = Color3.fromRGB(0,0,255)
end
Can’t you just convert the BrickColor into a color3 by doing MyBrickColor.Color
Sadly not, which is odd. Unless I’m doing it incorrectly.
I did some testing with that when you told me about it and just ran print(Team.TeamColor.Color)
and it just returned stuff like 0.356863, 0.603922, 0.298039
.
Is there a way to make it like Color3.fromRGB?
You can just multiply the whole thing by 255. 0.356863 * 255 = 91 which is “Red”
Edit: Or you could set it to be TextColor = Color3.new()
Oh I see, here is the updated code then
local Color = Player.Team.TeamColor.Color
local R,G,B
R = Color.R * 255
G = Color.G * 255
B = Color.B * 255
Text.TextColor3 = Color3.fromRGB(R,G,B)
Great!
A Simpler version of your code I think is a little easier is this
local Color = Player.Team.TeamColor.Color
Text.TextColor3 = Color3.new(Color.R,Color.G,Color.B)
Edit: Color3.new is basicly the same but on a scale of 0 to 1 instead of 0 to 255
Just tried this, seems to only be setting the color to white. (Team color is yellow, currently.)
Hmm. Thats what happens when you try to put rgb arguments in the Color3.new function. Use @Mr_Unlucky’s code and try that happens. If not try mine. If you tried both print the text color value and tell me
Are you manually changing the TeamColor in the explorer? If so, that is probably why, considering how it’s not designed to update whenever it’s changed.
This is how my code goes:
game:GetService("ReplicatedStorage").ChatUpdate.OnServerEvent:Connect(function(plr,text,color,staff)
local FilteredString = game:GetService("Chat"):FilterStringAsync(text, plr, plr)
local SendColor = game:GetService("Players")[plr.Name].Team.Name
local SendStaff = game:GetService("Players")[plr.Name]:GetRankInGroup(redacted)
local HandleRank = ''
if game.CreatorId == plr.UserId then
HandleRank = ''
elseif SendStaff == 31 then
HandleRank = ''
elseif SendStaff == 248 or SendStaff == 250 then
HandleRank = ''
elseif SendStaff == 249 or SendStaff == 251 then
HandleRank = ''
elseif SendStaff >= 252 then
HandleRank = ''
end
local Color = plr.Team.TeamColor.Color
local R,G,B
R = Color.R * 255
G = Color.G * 255
B = Color.B * 255
print('Handling Message: '..FilteredString..' From: '..plr.Name..' Ranking: '..SendStaff..' '..HandleRank..' Found Color? '..tostring(SendColor))
game:GetService("ReplicatedStorage").ChatUpdate:FireAllClients(plr.Name,FilteredString,SendColor,HandleRank,R,G,B)
end)
Handler:
game:GetService("ReplicatedStorage").ChatUpdate.OnClientEvent:connect(function(user,text,color,perm,R,G,B)
local newMsg = script.Frame:Clone();
newMsg.Hold.Player.Text = user
newMsg.Hold.Text.Text = text
newMsg.Hold.Player.TextColor3 = Color3.new(R,G,B)
newMsg.Hold.Badge.Image = 'http://www.roblox.com/asset/?id='..perm
newMsg.Hold.Parent = script.Parent
end)
I think this issue is that you’re multiplying R, G, and B by 255 and then using those color values onto Color3.new
and not Color3.fromRGB()
.
Try doing this instead:
game:GetService("ReplicatedStorage").ChatUpdate.OnClientEvent:connect(function(user,text,color,perm,R,G,B)
local newMsg = script.Frame:Clone();
newMsg.Hold.Player.Text = user
newMsg.Hold.Text.Text = text
newMsg.Hold.Player.TextColor3 = Color3.fromRGB(R,G,B)
newMsg.Hold.Badge.Image = 'http://www.roblox.com/asset/?id='..perm
newMsg.Hold.Parent = script.Parent
end)
Oh, oops. One momento, lemme change that
Edit, there we go. Thanks all.