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

How do you find the owner of a group through a script?

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?

2 answers

✓ Accepted answer

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)

1 comment

0

Thanks so much!

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

1 comment

0

GetRankInGroup caches. I'd recommend HttpService or GroupSevice

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