How to show game creator name on a text label

So, I want a text label for my custom game menu to show the owner of the game, and if the game is owned by a group, then show the group name.

Is this possible?

local creatorId = game.CreatorId
local creatorName = game.Players:GetNameFromUserIdAsync(creatorId)
print(creatorName)

This returns an error when I try it

I want it to show the creator even when the owner is not in-game

Probably because the game’s owner (creator) is a group, fortunately I was in the middle of creating a script more versatile for you.

local players = game:GetService("Players")
local groups = game:GetService("GroupService")

local function displayOwner()
	local creatorId = game.CreatorId
	if game.CreatorType == Enum.CreatorType.User then
		local success, result = pcall(function()
			return players:GetNameFromUserIdAsync(creatorId)
		end)
		
		if success then
			if result then
				print(result) --Creator's name (if a user).
			end
		else
			warn(result)
		end
	elseif game.CreatorType == Enum.CreatorType.Group then
		local success, result = pcall(function()
			return groups:GetGroupInfoAsync(creatorId)
		end)
		
		if success then
			if result then
				print(result.Name) --Creator's name (if a group).
			end
		else
			warn(result)
		end
	end
end

displayOwner()
1 Like

Did you publish the game your working on it in? If you don’t publish it the game doesn’t really exist.

1 Like

Its published! And the game owner is me, not a group.

Then that first script shouldn’t error (unless you incorrectly placed it in a local script).

https://developer.roblox.com/en-us/api-reference/property/DataModel/CreatorId

A lot of the DataModel’s properties don’t replicate across the client-server boundary (because they don’t need to).

OHHH, SO THATS MY PROBLEM, I guess RemoteEvents will be my solution.

FWIW: CreatorId is always non-zero. Blank files open an uncopylocked Roblox place called Baseplate owned by the Templates account. The problem is that it’s only set on the server.

IMHO best way to display this information is to set an attribute to the Workspace with the CreatorId. The client can then get this attribute or wait for it to exist if it doesn’t. You can then pass the value of that attribute to the code given in the thread’s first reply.

Let the engine handle replication for you, no need to remote up.

1 Like