Hello. I seem to be having an issue with updating my games round results.
This is the code that handles everything on the players stats and also tells which stats are higher than the other.
local function CalculateRoundResults()
local HighestKillsNumber, HighestDeathsNumber = 0, 0
for i, v in pairs(Players:GetPlayers()) do
local Kills = v:WaitForChild("leaderstats").Kills.Value
local Deaths = v:WaitForChild("Deaths").Value
local Streak = v:WaitForChild("leaderstats").Streak.Value
if Kills and Streak and Deaths then
if Kills > HighestKillsNumber then
HighestKillsNumber = Kills
HighestKillsUser = nil
HighestKillsUser = v
end
if Deaths > HighestDeathsNumber then
HighestDeathsNumber = Deaths
HighestDeathsUser = nil
HighestDeathsUser = v
end
return HighestKillsUser and HighestDeathsUser
end
end
end
Events.UpdateRoundResults:FireAllClients(HighestKillsUser, HighestDeathsUser)
but the problen is updating the gui on the client. Whenever i change the stats of other players, it doesn’t show the player that has the most stats on the gui but whenever i change the stats of the player that joined the server first, it would work which i dont undertsand.
Client code:
Events.UpdateRoundResults.OnClientEvent:Connect(function(KillsUser, DeathsUser)
local RoundGUI = Game_HUD.Main:WaitForChild("Round")
local RoundMain = RoundGUI:WaitForChild("Main")
local RoundResults = RoundMain:WaitForChild("Results")
RoundResults.Gamemode.Text = "Gamemode: <b>MODENAME</b>"
local MK = RoundResults:WaitForChild("List"):WaitForChild("MK")
local MD = RoundResults:WaitForChild("List"):WaitForChild("MD")
local YS = RoundResults:WaitForChild("List"):WaitForChild("You")
MK.Details.DisplayName.Text = "DisplayName"
MK.Details.Username.Text = "@<b>Username</b>"
MK.Details.Kills.Text = "Kills: <b>0</b>"
MK.Details.Deaths.Text = "Deaths: <b>0</b>"
MK.Details.Streak.Text = "Streak: <b>0</b>"
MD.Details.DisplayName.Text = "DisplayName"
MD.Details.Username.Text = "@<b>Username</b>"
MD.Details.Kills.Text = "Kills: <b>0</b>"
MD.Details.Deaths.Text = "Deaths: <b>0</b>"
MD.Details.Streak.Text = "Streak: <b>0</b>"
if KillsUser and DeathsUser == nil then
local FindPlayerHighestKills = Players:FindFirstChild(KillsUser.Name)
if FindPlayerHighestKills then
MK.Details.DisplayName.Text = FindPlayerHighestKills.DisplayName
MK.Details.Username.Text = "@<b>"..FindPlayerHighestKills.Name.."</b>"
MK.Details.Kills.Text = "Kills: <b>"..FindPlayerHighestKills:WaitForChild("leaderstats").Kills.Value.."</b>"
MK.Details.Deaths.Text = "Deaths: <b>"..FindPlayerHighestKills:WaitForChild("Deaths").Value.."</b>"
MK.Details.Streak.Text = "Streak: <b>"..FindPlayerHighestKills:WaitForChild("leaderstats").Streak.Value.."</b>"
end
elseif DeathsUser and KillsUser == nil then
local FindPlayerHighestDeaths = Players:FindFirstChild(DeathsUser.Name)
if FindPlayerHighestDeaths then
MD.Details.DisplayName.Text = FindPlayerHighestDeaths.DisplayName
MD.Details.Username.Text = "@<b>"..FindPlayerHighestDeaths.Name.."</b>"
MD.Details.Kills.Text = "Kills: <b>"..FindPlayerHighestDeaths:WaitForChild("leaderstats").Kills.Value.."</b>"
MD.Details.Deaths.Text = "Deaths: <b>"..FindPlayerHighestDeaths:WaitForChild("Deaths").Value.."</b>"
MD.Details.Streak.Text = "Streak: <b>"..FindPlayerHighestDeaths:WaitForChild("leaderstats").Streak.Value.."</b>"
end
elseif KillsUser and DeathsUser then
local FindPlayerHighestKills = Players:FindFirstChild(KillsUser.Name)
local FindPlayerHighestDeaths = Players:FindFirstChild(DeathsUser.Name)
if FindPlayerHighestKills and FindPlayerHighestDeaths then
MK.Details.DisplayName.Text = FindPlayerHighestKills.DisplayName
MK.Details.Username.Text = "@<b>"..FindPlayerHighestKills.Name.."</b>"
MK.Details.Kills.Text = "Kills: <b>"..FindPlayerHighestKills:WaitForChild("leaderstats").Kills.Value.."</b>"
MK.Details.Deaths.Text = "Deaths: <b>"..FindPlayerHighestKills:WaitForChild("Deaths").Value.."</b>"
MK.Details.Streak.Text = "Streak: <b>"..FindPlayerHighestKills:WaitForChild("leaderstats").Streak.Value.."</b>"
MD.Details.DisplayName.Text = FindPlayerHighestDeaths.DisplayName
MD.Details.Username.Text = "@<b>"..FindPlayerHighestDeaths.Name.."</b>"
MD.Details.Kills.Text = "Kills: <b>"..FindPlayerHighestDeaths:WaitForChild("leaderstats").Kills.Value.."</b>"
MD.Details.Deaths.Text = "Deaths: <b>"..FindPlayerHighestDeaths:WaitForChild("Deaths").Value.."</b>"
MD.Details.Streak.Text = "Streak: <b>"..FindPlayerHighestDeaths:WaitForChild("leaderstats").Streak.Value.."</b>"
end
elseif KillsUser == nil and DeathsUser == nil then
MK.Details.DisplayName.Text = "DisplayName"
MK.Details.Username.Text = "@<b>Username</b>"
MK.Details.Kills.Text = "Kills: <b>0</b>"
MK.Details.Deaths.Text = "Deaths: <b>0</b>"
MK.Details.Streak.Text = "Streak: <b>0</b>"
MD.Details.DisplayName.Text = "DisplayName"
MD.Details.Username.Text = "@<b>Username</b>"
MD.Details.Kills.Text = "Kills: <b>0</b>"
MD.Details.Deaths.Text = "Deaths: <b>0</b>"
MD.Details.Streak.Text = "Streak: <b>0</b>"
end
end)