Pop-up GUI with chat command if user haves a rank in group

I want to archieve a command like when you say for example !admin and you are a X role (or higher) in a roblox group then a GUI appears, but if the user do not have that rank or higher in the group can’t open the GUI

I have already seen some posts but noone included the group rank, only the command and open, but in my case I need a command, and open the GUI if the person is in the group and have a specific group rank or higher.

Thank you to all and have a good night/day. :slight_smile:

2 Likes

You can achieve this with the following:

GetRankInGroup
PlayerAdded
Chatted

If you’d like sample code let me know.

1 Like

I just read it and something I undestood but im veryyyy veryy bad scripting, if you can do you have any example?

Sure! Here is a quick example. This might not be optimal and I’d invite you to explore other responses as well as Lua isn’t my primary language.

local groupId = 1 -- the id of your group
local roleId = 1 -- the roleId you want access 

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(groupId) >= roleId then -- only create the chatted connection if there of the group rank
		plr.Chatted:Connect(function(msg)
			if msg == "!admin" then -- might be useful to add string.lower or simply do a search of the string to ensure it was said somewhere in the message
				-- make ui visible here, i'd recommend doing a fireclient and having some server code replicate the reciever to plrs of a certain group rank.
			end
		end)
	end
end)

I was readig the script trying to understand it but how can I use the fire server I mean the Ui I need to appear is called AdminP and it’s on starterGUI should I move it to replicate storage or how what should I add there?

He means to get the player’s gui and make the frame visible.

Example:

local groupId = 1
local roleId = 1

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(groupId) >= roleId then
		plr.Chatted:Connect(function(msg)
			if msg == "!admin" then
				plr.PlayerGui.ScreenGui.AdminP.Visible = true 
			end
		end)
	end
end)

Hope this helps :slightly_smiling_face:

1 Like

btw that’s sketchy with

local groupId = 1 -- the id of your group
local roleId = 1 -- the roleId you want access 
local GUI = game.ServerStorage.AdminGUI
game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(groupId) >= roleId then -- only create the chatted connection if there of the group rank
		plr.Chatted:Connect(function(msg)
			if msg == "!admin" then --
			local y = GUI:Clone()
            y.Parent = plr.PlayerGui
			end
		end)
	end
end)

the reason you should not have it like make visible is exploiters could use a thing called “Dex” to make it visible

1 Like

True, I did not include any anti-exploit methods in my piece of code; I kept it plain and simple. Whenever you can add an extra level of security to your game, you should go for it.

Make sure you use GetService() to reference ServerStorage, otherwise it won’t work.

i.e. game:GetService(“ServerStorage”).AdminGui

1 Like

Ohh thank you!! Thanks for helping me I needed this thing.

I didn’t knew a exploiter could see the gui if was not secured thank you!