Basically, in my game, at the end of each match (around 10 minutes or 600 seconds), a GUI pops up and says "The round is now over. %Playername% has won first place"
How do I make it so the GUI can detect who is in first place?
I am using a modified ROBLOX leaderboard that only has KOs. However, now that I know how leaderboard systems work, I'll eventually not have a script and just have a value in StarterPlayerScripts called "leaderstats" with all of the needed values as my gun system does everything.
local Use_DB = false
function saveStat(plr,val,key)
if plr then
plr:WaitForDataReady()
plr:SaveNumber(key,val)
end
end
function loadStat(plr,key,stat)
if plr then
plr:WaitForDataReady()
stat.Value = plr:LoadNumber(key,val)
end
end
game.Players.PlayerAdded:connect(function(player)
Stat = Instance.new("IntValue",player)
Stat.Name = "leaderstats"
KOs = Instance.new("IntValue",Stat)
KOs.Name = "KOs"
WOs = Instance.new("IntValue",Stat)
WOs.Name = "WOs"
KOs = Instance.new("IntValue",Stat)
KOs.Name = "DesperateFragger"
if Use_DP then
loadStat(player,"KOs",KOs)
loadStat(player,"WOs",WOs)
end
player.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
WOs.Value = WOs.Value +1
if Use_DP then
saveStat(player,WOs.Value,"WOs")
end
Cre = char.Humanoid:FindFirstChild("creator")
if Cre then
if Cre.Value then
if Cre.Value ~= player then
Cre.Value.leaderstats.KOs.Value = Cre.Value.leaderstats.KOs.Value +1
else
KOs.Value = KOs.Value -1
end
if Use_DP then
saveStat(Cre.Value,Cre.Value.leaderstats.KOs.Value,"KOs")
saveStat(player,KOs.Value,"KOs")
end
end
end
end)
end)
end)
