Give Player GUI if there in a Table

So I want to basically make I have a table I want the Players in the table to get a gui if there name is in that table

This is what I got

	local Allowed = {
	for i,v in pairs(Allowed) do
		player.PlayerGui.Music.Enabled = true

1 Like

So your for loop iterates twice and gives the player the music enabled. Instead what you want to do is

for _,v in ipairs(Allowed) do
   if player.Name == v then -- this checks that the player's name in quesiton is in the array
      -- enable music thing
      break -- we don't need to continue iterating

P.S. If you want to actively update those names, you’d also have to put the array outside the function, otherwise the array is constant and can only be changed for new servers.

wait let me see if this works :sweat_smile:

whats the different between ipairs and in pairs

The difference is that ipairs are used for arrays and pairs are used for dictionaries.

1 Like

I suggest you use:

if table.find(Allowed, Player.Name) then
player.PlayerGui.Music.Enabled = true