Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Kev_nn 4
5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by
Axdrei 107
5 years ago

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)
0
Thanks so much! Kev_nn 4 — 5y
Ad
Log in to vote
0
Answered by
valchip 789 Moderation Voter
5 years ago
Edited 5 years ago
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

0
GetRankInGroup caches. I'd recommend HttpService or GroupSevice User#19524 175 — 5y

Answer this question