Hello Developers, i’m currently building on a project(“the army of robloxia”) and i can’t make a ranking system like, if you pass a training you would be ranked by a instructor but it doesn’t work for me. Do you guys know how to make one?
2 Likes
Hello!
You will have to do this via group ranking system, (if some one passes, you rank them in the group and it matches that rank with a overhead GUI.)
But in order to do that you would need.
game.Players.PlayerAdded:Connect(function(newPlayer)
if newPlayer:IsInGroup(GroupId) and Player:GetRankInGroup(GroupId) == 120 then then
print ("Player is in group and ranked")
end
end)
There are some Tutorials on this subject already however.
Links :
https://developer.roblox.com/en-us/api-reference/function/Player/GetRankInGroup
https://developer.roblox.com/en-us/api-reference/function/Player/IsInGroup
2 Likes
Adding to what you’ve said,
I’d suggest adding a pcall
to GetRankInGroup
, simply because it’s a web signal, and can fail sometimes due to updates on the web,etc.
2 Likes
You can use datastore to save the players ranks and grant access to instructors to rank people. Try this:
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Data")
local Default = {
Rank = {
Type = "StringValue", -- The ClassName of the value that will be created
Value = "" -- Rank that the player gets when he joins for the first time
}
}
local Ranks = {
"Rank1",
"Rank2",
"Rank3",
"Rank4"
}
local Instructors = {
"Rank3",
"Rank4"
}
local Prefix = "." -- Change if you want to
local function CreateValue(Player, Name)
local Data = DataStore:GetAsync(Player.UserId)[Name] or Default[Name]
for _, Value in pairs(Data) do
local NewValue = Instance.new(Value.Type)
NewValue.Name = Name
NewValue.Value = Value.Value
NewValue.Parent = Player.Infos
end
end
Players.PlayerAdded:Connect(function(Player)
local Infos = Instance.new("Folder")
Infos.Name = "Infos"
Infos.Parent = Player
for Name, Value in pairs(Default) do
CreateValue(Player, Name)
end
Player.Chatted:Connect(function(Message)
local Msg = string.split(Message, " ")
if Msg[1] == Prefix.."rank" and Players:FindFirstChild(Msg[2]) and table.find(Ranks, Msg[3]) and table.find(Instructors, Player.Infos.Rank.Value) then
local Plr = Players:FindFirstChild(Msg[2])
Plr.Infos.Rank.Value = Ranks[table.find(Ranks, Plr.Infos.Rank.Value) + 1]
print("Old rank: "..Ranks[table.find(Ranks, Plr.Infos.Rank.Value) - 1].." | New rank: "..Plr.Infos.Rank.Value)
end
end)
end)
Players.PlayerRemoving:Connect(function(Player)
local Data = {}
for _, Values in pairs(Player.Infos:GetChildren()) do
Data[Values.Name] = {}
Data[Values.Name].Type = Values.ClassName
Data[Values.Name].Value = Values.Value
end
DataStore:SetAsync(Player.UserId, Data)
end
3 Likes