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

What is wrong with my leaderboard?

Asked by 10 years ago

What I am trying to do is if the player is in a group, a stat will show up as their rank in the group, if they are not in the group.. their stat will be "Guest". At the same time I am trying to make it so if they are in a certain rank in the group they will be on the team Bright Red, or team name DJ.

I don't see why this does not work except I may have assigned the players team incorrectly..

local playerStats = {} --this keeps a list of the stats for each player that enters the game

 game.Players.PlayerAdded:connect(function(player) --Added function
     local leaderstats = Instance.new("Model", player) --Make leadeerstats
     leaderstats.Name = "leaderstats" --Change the name...

     local grouprank = Instance.new("StringValue", leaderstats) --assign the variable
     grouprank.Name = "Rank" --set up value
     local rank = player:GetRoleInGroup(1066846) --Get the group rank from group

     if rank ~= 0 then --If user is in group...
         grouprank.Value = rank --Then assign them the rank
     else
        grouprank.Value = "Guest" --They are not in group so they get this rank on the leaderboard
     end
        if rank ~= 75 then --If user is rank number 75, assign them to team name DJ
        local team = game:GetService("Teams") --Get the Team service
        player.team = DJ --Change the players team to DJ, Should I do team color? problem could be right here
     playerStats[player] = leaderstats 
     end
end)

1 answer

Log in to vote
1
Answered by
ultrabug 306 Moderation Voter
10 years ago

It doesn't work because you got the ROLE of the player, not the number rank, so you can make another variable for the number rank like this:

local Nrank= player:GetRankInGroup(1066846)

Then instead of using 'rank' to determine the team they should be on, use this. But keep rank for the string ranking. nrank will be used instead, and rank will be used to give them the role they have, if they are not in the group, it will put them as guest anyways.

Fixed:


game.Players.PlayerAdded:connect(function(player) --Added function local leaderstats = Instance.new("Model", player) --Make leaderstats leaderstats.Name = "leaderstats" --Change the name... local grouprank = Instance.new("StringValue", leaderstats) --assign the variable grouprank.Name = "Rank" --set up value local rank = player:GetRoleInGroup(1066846) --Get the group rank from group local nrank=player:GetRankInGroup(1066846) grouprank.Value=rank if nrank == 75 then --If user is rank number 75, assign them to team name DJ player.TeamColor = BrickColor.new("Cyan")--Or color of the team 'DJ' end end)
0
When I tested it, it did not make me on the team. IntellectualBeing 430 — 10y
0
are you above number rank 75? ultrabug 306 — 10y
0
I changed it to a lower number when I tested it. IntellectualBeing 430 — 10y
0
hmm ultrabug 306 — 10y
View all comments (2 more)
0
I know why it did not work, it was my mistake. I left this in somehow... playerStats[player] = leaderstats IntellectualBeing 430 — 10y
0
okay ultrabug 306 — 10y
Ad

Answer this question