I have a LocalScript in StarterGui which is as follows:

local Admins = {USERID1, USERID2, USERID3}

local ParseAdmin = function(player) 
	for _, Id in pairs(Admins) do	
		if player.UserId == Id then	
			return true		
		end	
	end
end

game.Players.PlayerAdded:Connect(function(player)
	if ParseAdmin(player) then
		local gui = game.ReplicatedStorage.AdminManager:Clone()
		gui.Parent = player:WaitForChild("PlayerGui")
	end
end)

It is supposed to check if a player is an admin and if so then clone the admingui in ReplicatedStorage and set the player's playergui as it's parent. However, it's not working. What's wrong with it? The gui was not cloned .

5 comments

0

Maybe the PlayerGui is already loaded, and it continues to wait for that loaded signal due to :WaitForChild. Maybe instead, pause the thread with a CharacterAdded event at the beginning, and then just use :FindFirstChild()

0

That just didn't work

0

It doesn't make sense for this to be a local script. It seems more fit to me for it to be a server script inside ServerScriptService. Anyway, have you inserted the userid's into the table?

0

Of course, I've inserted my userid into the table.

0

does the If ParseAdmin(Player) evaluate to true?