So I have made custom player list with team, but how to make when there is no player in this team, the team frame become visible = false, but when there is a player in that team again it will be visible again. Using Custom Player List not Core GUI player list, So I supposed it’s kinda easier? But how? If someone know please let me know, thank you
I would use an event which is fired everytime a player changes team, look out for that, and then update the frame accordingly.
local Teams = game:GetService("Teams")
local function update()
for i, team in pairs(Teams:GetTeams()) do
if #team:GetPlayers() == 0 then
print(string.format("There are no players on the %s team.",team.Name))
elseif #team:GetPlayers() > 0 then
print(string.format("There are players on the %s team.",team.Name))
end
end
end
update()
for i, team in pairs(Teams:GetTeams()) do
team.PlayerAdded:Connect(update)
team.PlayerRemoved:Connect(update)
end
local Teams = game:GetService("Teams")
local function update()
for i, team in pairs(Teams:GetTeams()) do
local teamFrame = Frame:FindFirstChild(“team.Name)
if #team:GetPlayers() == 0 then
teamFrame.Visible = false
elseif #team:GetPlayers() > 0 then
teamFrame.Visible = true
end
end
end
update()
for i, team in pairs(Teams:GetTeams()) do
team.PlayerAdded:Connect(update)
team.PlayerRemoved:Connect(update)
end
So because my team frame name is same as team name i can make it like this?
Also this is kinda out of topic, do you know how to make scrolling frame canvas size depends on child(player inside), so more people inside its enlarge, because sometimes its bothering when you make canvas size so big and yeah you still can scroll even maybe the child is only 2 people, but because the canvas size manually big you still can scroll. But i dont know how, many people recommend me but using offset, while I use Scale
If the team frame is the same as the team name, you can do it like this:
ScreenGui[team.Name].Visible = false
Yes well similar to what i sent above just now, so now the problem is do u know , well sorry a little bit out of topic but still about the player list, how to make scrolling frame canvas size resize according to how many child (player) inside it, more players more bigger , the Y. I use scale not offset
And make the canvas size to 0,0,0,0?
Yes, I think that should work.
Thank you i will try, i will contact after i try but since this is not the topic, i will mark your solution as my answer for this forum
Also i do it with script right? Not local script
if it’s for a GUI, it must be a local script.
well this is just for personal curiosity, is it good to use team destroy when no player and create again if someone come and this player should be on that team?
In my opinion it would be better to have all the teams created and not delete it when there is no player in it and create it when someone enters and should be in that team.