This answer is meant to be used as a reference
I don't recommend using IsInGroup, GetRoleInGroup or GetRankInGroup as those functions cache, meaning they'll store that data until the player joins a different/new server (if I recall correctly). However, there's an alternative to these functions: GroupService! :O I'm pretty new to it too, so please bear with me.
The group service has a function called GetGroupsAsync, where it'll return the data of the player in a specific group they're in. This can be done by doing the following:
local PlayersGroup = GroupService:GetGroupsAsync(PlayerUserId)
There we go! :D We now have a function set up for the player. But now, we gotta check if the player's in the group! :O No problem there, as along with the data returned (with the array), it'll return the group's id too! :D An example of this being:
local PlayersGroup = GroupService:GetGroupsAsync(PlayerUserId)
for I, v in next, PlayersGroup do
if v.Id == Group_Id then
end
end
Yay! :D Now we'll know if the player's in the group! ^^ But now, we gotta return the information, right? No problem! The function also has that covered. (Cue sunglasses emoji). An example being:
local PlayersGroup = GroupService:GetGroupsAsync(PlayerUserId)
local RankInGroup, RoleInGroup = 0, 'Unknown'
for I, v in next, PlayersGroup do
if v.Id == Group_Id then
RankInGroup = v.Rank
RoleInGroup = v.Role
end
end
Now it'll return the information if the player's in the group! :D If not, it'll return 'Unknown'. :o Welp, I think this about sums it up. XP
St00f touched on but neva explained (10/10 gramm3r)
GroupService - A service that returns loads of info about/with groups.
Caching - In a nutshell: Where when it gets the result, it stores the data somewhere so that it can just get the data when something's prompted again. (Think of a grocery list, and how it's a go-to when shopping for dinner)
GetGroupsAsync - Returns what groups a player's in, and what their role in it is. (Who they're in that group)
I hope this helped! :D If you have any questions, please let me know! ^^
1 comment
Please use a code block