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

How to make a playerlist team color adaptive?

Asked by 4 years ago

i want to change the background color by the teamcolor.



local players = game:GetService("Players") local frame = script.Parent local slots = frame.slots local temp = frame.Template local players_table = {} local dir = "Out" local style = "Quad" local dur = 0.5 local function cleanup(slot) repeat wait() until slot.Position.X.Offset == 400 slot:Destroy() end local function remove(leaving) if leaving then players_table[leaving] = nil local slot = slots:FindFirstChild(leaving) slot:TweenPosition(UDim2.new(0, 400, 0, slot.Position.Y.Offset), dir, style, dur, true) local cor = coroutine.wrap(cleanup) cor(slot) end end local function add() local chil = players:GetChildren() for c = 1, #chil do if players_table[chil[c].Name] == nil then players_table[chil[c].Name] = 1 local slot = temp:Clone() slot.Name = chil[c].Name slot.Text = slot.Name slot.Parent = slots end end end local function adjust(leaving) add() remove(leaving) local count = 0 for key, value in pairs(players_table) do count = count + 1 local slot = slots:FindFirstChild(key) local ypos = 30 + (40+2)*(count-1) if game.Players.LocalPlayer.Team == game.Teams["Neighbor"] then slot.BG.ImageColor3 = Color3.new(255, 0, 0) elseif game.Players.LocalPlayer.Team == game.Teams["Lobby"] then slot.BG.ImageColor3 = Color3.new(163, 162, 165) elseif game.Players.LocalPlayer.Team == game.Teams["Visitors"] then slot.BG.ImageColor3 = Color3.new(220, 188, 129) end slot:TweenPosition(UDim2.new(0, 0, 0, ypos), dir, style, dur, true) end end players.PlayerAdded:connect(function() adjust(nil) end) players.PlayerRemoving:connect(function(leaving) adjust(leaving.Name) end) adjust()

1 answer

Log in to vote
0
Answered by
LeadRDRK 437 Moderation Voter
4 years ago

Team contains a property called TeamColor which is a BrickColor value. However, we can use the Color property of BrickColor to get the Color3 value that is used for ImageColor3.

Having said that, you can achieve "adaptive" color using this:

local Team = game.Players.LocalPlayer.Team
slot.BG.ImageColor3 = Team.TeamColor.Color
0
i mean , when the player joins a team to update the ImageColor3 2 DragosGames 43 — 4y
Ad

Answer this question