Is it possible to check if a user is in a group, from their User Id alone?
I'll give my User Id '19497313' in the example below.
I've tried:
if 19497313:IsInGroup(4172264) then print("User is in group.") end
But it doesn't seem to work, as I'd imagine that the 'IsInGroup' function only works with strings, not integers.
Player:IsInGroup()
operates on instances (a form of userdata
), not strings or integers. Instead, you'd want to use GroupService:GetGroupsAsync()
like so:
local Services = { Group = game:GetService("GroupService") } local TargetUserId = 1 local TargetGroupId = 1 local UserGroups = Services.Group:GetGroupsAsync(TargetUserId) for Index = 1, #UserGroups do local GroupData = UserGroups[Index] if TargetGroupId == GroupData.Id then print("Player with the target user ID is in the group!") break end end
The Wiki API documentation for this method can be found here.