How to detect game owner

Simple question but cant find answer, how do I get what player is the owner of the game through a script? :slight_smile:

5 Likes

You can get the Owner’s UserId by using game.CreatorId and then comparing it against the UserId of any player that joins.

E.g.

local ownerId = game.CreatorId

game.Players.PlayerAdded:Connect(function(player)
    if player.UserId == ownerId then
        print("got the owner!")
    end
end)
20 Likes

Thanks, I simply forgot about creator ID, 11:00pm problems lol

8 Likes