What I would recommend is giving them the GUI when the player is added (server-script).
local Players = game:GetService('Players')
local GUI = GUI_LOCATION
local Whitelisted = {
['Hello_world'] = 000000,
['Player'] = 111111,
-- Username = userid.
}
local function PlayerAdded(Player)
if table.find(Whitelisted, Player.UserId) then
GUI:Clone().Parent = Player.PlayerGui
end
end
local GetPlayers = Players:GetPlayers()
for i = 1, #GetPlayers do
local Player = GetPlayers[i]
coroutine.resume(coroutine.create(function()
-- Runs the PlayerAdded in parrallel for every player that was added before the event is fired.
-- Unexpected delays and WaitForChild()'s can cause this event to not fire when the player is added.
PlayerAdded(Player)
end))
end
Players.PlayerAdded:Connect(PlayerAdded)
Make sure the GUI’s property (ResetOnSpawn is equal to false, otherwise you’ll need to clone the GUI to them everytime their character is added as well.)