Good morning,
I was wondering if I could get help with using the api. I was wondering how I can print if a group has no owner by id. I’ve never used the api so I have no idea.
Thanks.
Good morning,
I was wondering if I could get help with using the api. I was wondering how I can print if a group has no owner by id. I’ve never used the api so I have no idea.
Thanks.
The following line of code finds info on a group using :GetGroupInfoAsync(), a function of GroupService.
print(game:GetService("GroupService"):GetGroupInfoAsync(ID).Owner ~= nil)
-- Will print true or false whether a group has an owner
Here’s a function I wrote which accepts a group’s ID as an argument and returns whether or not that group has an owner.
local groups = game:GetService("GroupService")
local function doesGroupHaveOwner(groupId)
local success, result = pcall(function()
return groups:GetGroupInfoAsync(groupId)
end)
if success then
if result then
if result.Owner then
return true
else
return false
end
end
end
end
print(doesGroupHaveOwner(1)) --true
print(doesGroupHaveOwner(13)) --false