How to use GetRoleInGroup properly

Hello im trying to make an admin gui for my game and it is working out great so far. The only issue i ran into is that getting the players role in the group does not work properly for me. Even if the players role on the group is not the role specified, the script still fires regardless and i do not know why this is.

game.Lighting.GUIRemotes.HakerRepelant.OnServerEvent:Connect(function(plr,passcode)
	
	local playergroupid = plr:GetRoleInGroup(8161135)

	if playergroupid == "Owner" or "Co-Owner" or "Admin" or "Moderator" or "Developer" then
		
		if passcode == "FillerPassCodeForDevForum" then
			
			if plr:FindFirstChild("AdminMenuAcess") == nil then
			
			local AdminMenuAcess = Instance.new("Folder",plr)
			AdminMenuAcess.Name = "AdminMenuAcess"
				
			end	
		end	
	end
end)
1 Like

for example in this, even if the player is not the correct rank in the group, it still fires (if they have the passcode right)

if playergroupid == "Owner" or playergroupid == "Co-Owner"...

You just put an or operator without making it equal to something.

1 Like

Sorry elaborate what you mean by this

Not sure why you’re holding your remotes in lighting but try this:

game.Lighting.GUIRemotes.HakerRepelant.OnServerEvent:Connect(function(plr,passcode)
	local playergroupid = plr:GetRoleInGroup(8161135)

	if table.find({"Owner", "Co-Owner", "Admin", "Moderator", "Developer"}, playergroupid) then
		if passcode == "FillerPassCodeForDevForum" then
			if not plr:FindFirstChild("AdminMenuAcess") then
			
			local AdminMenuAcess = Instance.new("Folder")
			AdminMenuAcess.Name = "AdminMenuAcess"
			AdminMenuAcess.Parent = plr -- better performance

			end	
		end	
	end
end)
1 Like

Im holding remote events in lighting to add an extra layer of security from exploiters and thank you i will try this

1 Like

Exploiters could still see everything in lighting lol

1 Like

aw, well its worth it if they get confused for a couple seconds, i left a few local scripts named “1 shot admin script” that litteraly just trolls hackers who reads it

What I meant is that when you did if playergroupid == "Owner" or "Co-Owner", it always returns true. What I mean:

print("ThisIsAString" or true)

Output: ThisIsAString

What you did:

if playergroupid == "Owner" or "Co-Owner" or "Admin" or "Moderator" or "Developer" then
1 Like

ah, so with the table.find its actually testing if every single one of the values are the ones i specified instead of true?

Yes, that’s about right. You can also do that.

1 Like