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 comment
i mean , when the player joins a team to update the ImageColor3 2