How do I check if a player is the creator of a game?

I want to make an admin gui model. I want it to detect who the creator of the game or the owner of the creator group is so they get access to the gui without having to set it up every time they put it into their game. How do I do that?

2 Likes
local Player = game.Players.LocalPlayer

if Player.UserId == game.CreatorId then
    print("Its the Creator")
end

This should work, it checks if the Player Has the Same UserId as the Game’s Creator.
In order for this to entirely work, you need to test it in game Because you If you test it in Studio,
It will give the UserId of the Username “Templates

4 Likes

You could do this:

game.Players.PlayerAdded:Connect(function(Player)
   if Player.UserId == game.CreatorId  then
     print("Player is the owner!")
     GUI.Parent = Player.PlayerGui
  end
end)
2 Likes

Alternatively and more conveniently, you can get the owner of the games id through

local CreatorID = game.CreatorId

You can read up on it with this post

2 Likes
game.Players.PlayerAdded:Connect(function(plr)
	if game.CreatorType == Enum.CreatorType.User then
		if plr.UserId == game.CreatorId then
			local E = script.Parent.OwnerGui:Clone()
			E.Parent = plr.PlayerGui
		end
	elseif game.CreatorType == Enum.CreatorType.Group then
		if plr:IsInGroup(game.CreatorId) then
			local A = script.Parent.OwnerGui:Clone()
			A.Parent = plr.PlayerGui
		end
	end
end)

This works for games uploaded to my profile but now everyone in my group, no matter what rank they are has access to the gui somehow. I only want the owner of the group to have access to the gui

If you read the documentation you had copied your code from, you would notice your second statement detected users who are in the group, not the owner.

After detecting the game was created by a group, you can use GetGroupInfoAsync to find out further information about the group, such as the owner of the group.

local PlaceInfo = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
local GroupService = game:GetService("GroupService")

	elseif game.CreatorType == Enum.CreatorType.Group then 
		if plr:IsInGroup(game.CreatorId) then
            GameOwner = GroupService:GetGroupInfoAsync(PlaceInfo.Creator.CreatorTargetId).Owner
            if plr == GameOwner then
			    local A = script.Parent.OwnerGui:Clone()
			    A.Parent = plr.PlayerGui
            end
		end
	end

Just use

local Creator = game.CreatorId
--and use 
if plr:IsInGroup(Creator) and plr:GetRoleInGroup(GroupName) == role then -- or do plr:GetRoleInGroup(groupName,role), I haven't really dove deep into group parts but i hope this helps
 --code here for gui
end