Cannot get game.creatorid from Client

I did, still nothing (30charzzzzzzzzzzzzzzzzz)

So this happen

This was supposed to happen

Still dosent work

I tried it, dosen’t work. (30charzzzzzz)

1 Like

In my opinion, I wouldn’t automate this via code, and I’m sure most other games with credits / loading screens don’t do it that way either.

Make the UI and TextLabels to credit whomever, i.e a “Made by” followed by your name or even use a frame with a UIListLayout to credit multiple people.

They likely want it to be dynamic so that if they change their username the in-game label does to, without them having to manually change it.

– SERVER SCRIPT –

local players = game:GetService("Players")
local creatorId = players:GetNameFromUserIdAsync(game.CreatorId)
local replStorage = game:GetService("ReplicatedStorage")
local creatorRemote = replStorage:WaitForChild("CreatorRemote")

players.PlayerAdded:Connect(function(player)
	creatorRemote:FireClient(player, name)
end)

– CLIENT SCRIPT –

local replStorage = game:GetService("ReplicatedStorage")
local creatorRemote = replStorage:WaitForChild("CreatorRemote")

creatorRemote.OnClientEvent:Connect(function(player, name)
	--do stuff with name
end)

Make a RemoteEvent instance named “CreatorRemote” and put it directly inside the ReplicatedStorage folder, the server script can go in Workspace or ServerScriptService and the local script can go in StarterPlayerScripts or StarterCharacterScripts or some other suitable location.

Theres a problem: All I need is the CreatorId, but I can’t use it in localscripts, meaning that I can’t do nothing with the name

GetPlayerByUserId returns that User’s Player instance if they are in the game. You want to use GetNameFromUserIdAsync(userId) instead. I recommend wrapping this in a pcall to avoid any API failure errors.

local erroredName = "[Unknown]" -- in the event of an error this will be what will be returned.
local function getNameFromUserId(userId)
    local s, d = pcall(function() -- s = successful, d = data (the error or the name)
        return Players:GetNameFromUserIdAsync(userId) -- if there is no error, this will become our d variable.
    end) 
    if not s then return erroredName end -- if errored, return our placeholder name instead
    return d -- return actual name
end

print(getNameFromUserId(1)) -- "ROBLOX" or "[Unknown]" (if errored)
1 Like

It’s fetched from a server script, then sent to a local script, check above. I didn’t realize you were using the wrong function but I’ve changed it to “GetNameFromUserIdAsync()”.