Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a script that only certain ranks above can only join?

GroupId = "210856"

function onPlayerEntered(newPlayer)
	if not newPlayer:IsInGroup(GroupId) then
		newPlayer:remove() 
	end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

1 answer

I do not recommend using GetRankInGroup / GetRoleInGroup. These two functions will cache whatever is returned for the duration of that server.

GroupService supports a function called GetGroupsAsync(int64 UserId) whose returned values will not cache.

The main things you're looking for here are Name, Id, Rank, and Role. These ones represent the Group Name, Group Id, RankId, and Role (respectively).

The last two represent that of what the player has if you are confused. You can read more here.

An example would be:

for I, V in next, game:GetService("GroupService"):GetGroupsAsync(73735943) do
	print(V.Name, V.Id, V.Rank, V.Role)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.