I am trying to find what a group owner's name and ID is from a script in a group game. I have tried using the following code:
local creator = game.CreatorId
but it gives the group ID, not the group owner's ID. Any ideas on how to find who the group owner is?
Hello, Kev!
Have you heard about GetGroupInfoAsync function?
This should help you:
local groupId = 0 local group = game:GetService("GroupService"):GetGroupInfoAsync(groupId) local owner = group.Owner local ownerName = owner.Name local ownerUID = owner.Id print(group.Name .. "'s owner name is " .. ownerName .. " and his UserId is " .. ownerUID)
local groupid = 1 --put your group id here game.Players.PlayerAdded:Connect(function(player) if player:GetRankInGroup(groupid) == 255 then print("The owner of the group has joined the game") print("Owner: "..plr.Name) print("Owner's UserId: "..plr.Name else print("A player has joined the game") end end)
The highest rank in a group is rank 255 (aka the rank of the group owner). We check if the player who joined is the owner of the group by checking his in a certain group.
Incapaz said that :GetRankInGroup()
caches, I do not think that is true but if it really does you can use http://wiki.roblox.com/index.php?title=API:Class/GroupService/GetGroupInfoAsync