How can I make this script only work if they are a certain rank in a group?

Hello my name is pocvq,

I made a custome admin panel and you open it y pressing “m” on the keyboard but right now anyone can use it which is bad because they can ban kick and give any amount of cash I want it to only execute if the player is a certain rank in the group how would I do this?

Script

local Player = game:GetService(“Players”).LocalPlayer

local mouse = Player:GetMouse()

local PlayerGUI = Player:WaitForChild(“PlayerGui”)

local gui = script.Parent.Frame

mouse.KeyDown:Connect(function(key)

if key == “m” then

gui.Visible = not gui.Visible

end

end)

The following should do what you want:

GROUPID = 3336691
mouse.KeyDown:Connect(function(key)
	if key == "m" then
        if not Player:IsInGroup(GROUPID) then
	   	    return
	    end
		gui.Visible = not gui.Visible
	end
end)

However make sure additionally to check that the player is in the group on any server side requests too. As anything client-side can be manipulated.

Wait but doesnt this only checkk if they are in the group because I want them to be or be above the rank 254

My apologies I misread, here is the code you want:

GROUPID = 3336691
MIN_RANK = 254

mouse.KeyDown:Connect(function(key)
	if Player:GetRankInGroup(GROUPID) < MIN_RANK then
		return
	end
	if key == "m" then
		gui.Visible = not gui.Visible
	end
end)

Thank you so much keep up helping lol

1 Like