Help making custom team leaderboard work (Solved)

Hi, so we’re trying to make a team leaderboard work, which is that the player names show on the leaderboard depending on which team they are, we tried tons of ways but can’t seem to figure it out, I’ll show you the picture of the UI and where it’s located so maybe one of you guys can help.


image
All the team frames are structured the same.

2 Likes

Maybe get teams of all of the players on the server and put them in one of the corresponding sections?

how would we do the usernames tho and the viewportframes

My solution should work but I would rather use the solution by the person below.

When a player is added, have a script go through the players service and find each of the player’s PlayerTeam property. Depending on the value of that property, put their name and avatar icon onto the one of the corresponding sections on the leaderboard. You will need local scripts (I think?) to update the gui.

1 Like

make a team variable such as
local team = game.Teams.YourTeam

you can use the function below to get all players in a team.
team:GetPlayers()

then you can put it through a loop such as

for _, v in pairs(team:GetPlayers()) do
   print(v.Name) --// print the player name
end

this gets all of the players in a for loop and prints their name, then you just modify it with and make it clone a textlabel or something and make it display the player name. this is just an example, i am not going to make the entire script for you.

1 Like

i’d suggest instead of depending on 2 imagelabels, you make a frame with a list layout that once you open the menu it duplicates the imagelabels into their frames (where the uilistlayout is located)

I made it work using your script thank you

Just one more question ,do you know by chance how to make a leaderstats where the value is points but the leaderstat goes to the team not the player and then make the points go to on the GUI?

sorry about the no reply, was kind of away. yeah instead of making a leaderstat script that attaches to the player, you can make one instead on the server or replicatedstorage, by making a script like this, no events required. this will make a points value inside of replicatedstorage, and you also may alternatively create an intvalue in the directory you wish to have the team points instead of making them via script, it may also cause bugs so i’d suggest you create an IntValue named Team1Points in ReplicatedStorage and see if the local script i’ve provided below works for you.

local Team1Points = Instance.new("IntValue", game.ReplicatedStorage) --// this makes an int value in replicatedstorage
Team1Points.Name = "Team1Points" --// name it so its not just a basic 'IntValue'
Team1Points.Value = 0

then you may add this into a textlabel (localscript)

while task.wait() do
   script.Parent.Text = "Points: "..game.ReplicatedStorage.Team1Points.Value --// gets the value we created earlier
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.