Hi there! I am trying to make a script that executes something when the owner joins. However when a game is a group game, game.CreatorId returns the groupid.
Is there a way to get the owner from the group when the game is a group game? I mean, the user who gets that owner tag in the playerlist?
You could use GetGroupInfoAsync using Group Service. This returns a dictionary where you can index to the Owner which gets the player and get the UserId out of that
I would suggest checking player’s rank in the group
I’ll refer to the playerlist script here.
if game.CreatorType == Enum.CreatorType.Group then
local success, result = pcall(function()
return player:GetRankInGroup(game.CreatorId) == 255
end)
if success and result then
-- PLAYER IS AN OWNER
end
end
PS: If you want to check both you can always change it to
local success, result = pcall(function()
return game.CreatorType == Enum.CreatorType.Group and player:GetRankInGroup(game.CreatorId) == 255 or game.CreatorId == player.UserId
end)
if success and result then
-- PLAYER IS AN OWNER
end