Why won't this Gui clone?

Im trying to make a screen gui clone for admins only.
script:

game:GetService("Players")
local og = script.Parent
local new = og:Clone()

game.Players.PlayerAdded:Connect(function(player)
	if player.UserId == --my ID or player.UserId == another Id then
		wait(5)
		new.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
	end
end)

i get this error

ServerScriptService.Sperat.Show:8: attempt to index nil with 'WaitForChild'

Edit: i see what I did wrong, I mentioned the local player from the server, but how would I re-write it?

LocalPlayer is only visible from the client, not the server, change that line to this

new.Parent = player:WaitForChild("PlayerGui")
1 Like