PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

IsInGroup

The IsInGroup Player function sends a request to the Roblox website asking whether a player is a member of a group, given the ID of that group.

##Note
Using this in a Script, as opposed to a LocalScript, will not get you the most up-to-date information. If a player leaves a group while they are in the game, IsInGroup will still think they’re in that group until they leave. However, this does not happen when used with a LocalScript.

This is because the method caches results, so multiple calls of IsInGroup on the same player with the same group ID will yield the same result as when the method was first called with the given group ID. The caching behavior is on a per-peer basis: a server does not share the same cache as a client.

Parameters

Name Type Default Description

The groupId of the specified group.

Returns

Return Type Summary

A boolean indicating whether the player is in the specified group.


Code Samples


How to Check if a Player is in a Group

The below example will print “Player is in the Roblox Fan club!” if the newly added player is in the group with a groupId of 7.

game.Players.PlayerAdded:Connect(function(newPlayer)
   if newPlayer:IsInGroup(7) then                    
      print "Player is in the Roblox Fan club!"     
   end
end)