Hi,
I modified a BTS Leaderboard script to use it as a gui results screen. I started a server of 2 in studio and executed this code. When this piece of code is executed, it clones a gui into one player's PlayerGui. Only one player's PlayerGui, no one else's. There is no errors even. I am so confused right now?
local msgui = WinGui:Clone() for i, player in pairs(game.Players:GetChildren()) do msgui.Parent = player.PlayerGui
You made a copy in the first line.
Later, in the loop, you are moving that single copy. So it just ends up in the last player in the loop.
The fix is simple; just define msgui
inside the loop so that a new one is made per player:
for i, player in pairs(game.Players:GetPlayers()) do local msgui = WinGui:Clone() msgui.Parent = player.PlayerGui end
As a side note, it's recommended to use :GetPlayers()
instead of :GetChildren()
on the players service to get the list of playing players.