Overhead GUI Rank system

How do I make a rank system?
type I opened a total of boxes there I get a rank

RANKS%201
ranks2

I’ll try to explain it quickly.

I wanted to make a system of rank with style these simulators, example you collected a total of blocks ai you receive a new rank, I really wanted to know how I do it, I already saw several tutorials is not able to find one explaining how to do, thank you

•It is yes and my first time using the dev forum, sorry guys

5 Likes

One way you can do this is by going through a table with keys that are the name of the rank and values that are the number you need.

4 Likes

This is actually quite easy.
The way I would do this would be having a while wait() do loop
Inside of the loop it would check if your stats are greater than one value, let’s say “Fresh Unboxer” (or 10) and less than another value “Box Cutter” (25) if it is then it would set your overhead text to Fresh Unboxer.

5 Likes

I find it interesting, I’ll try to do something like what you said, thanks

3 Likes

Another way you can do it is easier to use. I wrote simple code if it’s just on the leaderboard. Script:

local functions = {}
functions.Create = function(p)
	if p then
		if p:IsA("Player") then
			local ls = Instance.new("Folder", p)
			ls.Name = "leaderstats"
			local iv = Instance.new("IntValue", ls)
			iv.Name = "Boxes Unboxed"
			iv.Value = 0
			local rn = Instance.new("StringValue", ls)
			rn.Name = "Rank"
			rn.Value = "Loading"
		end
	end
end
game.Players.PlayerAdded:Connect(function(p)
	functions.Create(p)
end)
local Ranks = {
	["Noob Unboxer"] = 0,
	["Good Unboxer"] = 10,
	["Great Unboxer"] = 25
}
game:GetService("RunService").Heartbeat:Connect(function()
	for _,v in pairs(game.Players:GetPlayers()) do
		if v:FindFirstChild("leaderstats") then
			local ls = v:FindFirstChild("leaderstats")
			if ls:FindFirstChild("Boxes Unboxed") and ls:FindFirstChild("Rank") then
				local bu = ls:FindFirstChild("Boxes Unboxed")
				local r = ls:FindFirstChild("Rank")
				spawn(function()
					for k,v in next, Ranks do
						print(k)
						if bu.Value >= v then
							r.Value = k
						end
					end
				end)
			end
		end
	end
end)
wait(5) --remove this wait 5 and things under it
for i = 1,25 do
	for _,v in pairs(game.Players:GetPlayers()) do
		v:WaitForChild("leaderstats")["Boxes Unboxed"].Value = i
	end
	wait(.3)
end

Make sure it’s in a server script.

4 Likes

Thanks, I’ll try to do according to this script

3 Likes

@profak’s suggestion, implemented in code:

local Ranks = { -- Store them in ascending order!
    {Name = "Noob Unboxer", Color = Color3.fromRGB(--[[colors here]]), Score = 0},
    {Name = "Fresh Unboxer", Color = Color3.fromRGB(), Score = 10},
    {Name = "Box Cutter", Color = Color3.fromRGB(), Score = 25},
 -- the other ones
}

local function GetRank(score)
    for i,rank in ipairs(Ranks) do
        if score < rank.Score then
            return Ranks[i-1]
        end
    end
end

Also, I wouldn’t do this every single heartbeat or wait(), that is definitely too much work for just an overhead rank. I would probably let it update every 3-5 seconds, 10 would work even:

while wait(5) do
    local rank = GetRank(player.leaderstats.BoxesUnboxed.Value)
    RankGuiLabel.Text = rank.Name
    RankGuiLabel.TextColor3 = rank.Color
end

In fact, I would hook this to BoxesUnboxed's Changed event just to guarantee consistency:

player.leaderstats.BoxesUnboxed.Changed:Connect(function(newValue)
    local rank = GetRank(newValue)
    RankGuiLabel.Text = rank.Name
    RankGuiLabel.TextColor3 = rank.Color
end)
6 Likes

thank you very much, I can now have a basic notion

2 Likes

I forgot ipairs existed. Your suggestion is a good idea.

3 Likes

Thank you to all who are helping me.

3 Likes

So:

  1. You have to define player. This would be done using the game.Players.PlayerAdded event:
game.Players.PlayerAdded:Connect(function(player)
    --do something with `player`
end)
  1. You have to create the leaderstats Folder that goes inside the player and the BoxesUnboxed IntValue that goes inside leaderstats. Note that this will create a leaderboard that all players can view from the player roster:
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"

local BoxesUnboxed = Instance.new("IntValue")
BoxesUnboxed.Name = "BoxesUnboxed"
BoxesUnboxed.Parent = leaderstats

leaderstats.Parent = player
  1. Color3.fromRGB accepts three values for red, green, and blue, each ranging from 0 to 255, as the dev wiki would say.

  2. Your while loop is malformed, ditch the loop as a whole:

BoxesUnboxed.Changed:Connect(function(newValue)
    local rank = GetRank(newValue)
    RankGuiLabel.Text = rank.Name
    RankGuiLabel.TextColor3 = rank.Color
end)
  1. RankGuiLabel has to be defined, just make a StarterCharacter in StarterPlayer with this overhead gui already created in it, using a BillboardGui offsetted a few studs upward, then you have to navigate to it from player.Character and define it from there:
local character = player.Character
if character then

    --Change this to where the gui is in the character
    local gui = character.BillboardGui

    --Change this to where the label is in the gui
    local RankGuiLabel = gui.RankGuiLabel

    --change RankGuiLabel's properties
end

Note that nothing here is in order or complete, you will need to do some work on your part to fit the pieces together. Try looking through the dev wiki for more tutorials or answers to your questions, and if you can’t find it there, you can ask here.

4 Likes

@profak

No.

Having pointless background loops is bad code. You should instead only be updating the information based on if the value changes (step in, GetPropertyChangedSignal). An example would be within what @goldenstein64 posted.

3 Likes

You can just change it to BlocksMined, since you aren’t actually using the BoxesUnboxed statistic in your game.

1 Like