How to script a Admin Button Only and VIP Server Owner only

How do i script Admin only Button?
and an VIP Server only Button

if you decide to help me thank you so much
if you think i made you do full script NOTE

But if you decide to script all i would appreciate it
But if you decide only 1 its alright as long as you helped

Because I’m bored so I made you some code you want

Admin Button Only:

local groupId = 0
local rankId = 0

local admins = {
	"admin"
}

-- Admin Group
game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(groupId) == rankId then
		script.Parent.MouseClick:Connect(function()
			-- Code
		end)
	end
end)

-- Admin Game
game.Players.PlayerAdded:Connect(function(plr)
	for _,v in pairs(admins) do
		if plr.Name == v then
			script.Parent.MouseClick:Connect(function()
				-- Code
			end)
		end
	end
end)

VIP Server Owner Only:

game.Players.PlayerAdded:Connect(function(plr)
	if plr.UserId == game.PrivateServerOwnerId then
		-- Code
	end
end)
1 Like

Thank you so much @ryanhawari17

You can use table.find instead of a pairs loop as it is much faster (use ipairs for arrays and pairs for dictionaries)

local index = table.find(admins, plr.Name)

if index then
   -- ...
end

Thank you so much @Artzified ill try that