game.CreatorId in client-side test environments is 0

I’ve got a simple block of code in a LocalScript that destroys it if the player is not the game’s owner:

if player.UserId ~= game.CreatorId then
    print(player.UserId, game.CreatorId)
    wait()
    script:Destroy()
end

However, it has one issue: in a test environment (Accurate Play Solo, Local Server), game.CreatorId is always 0 on the client. This means that the script will always be removed.

This behavior is unintuitive and probably unintentional. It creates bugs in code, and breaks scripts like the one I showed.

A temporary fix to this is to simply add a second condition, game.CreatorId ~= 0, but I should not have to do this, and trying to debug this is a waste of a time (especially when you don’t know the cause).

12 Likes

This is not a bug, it’s been like this forever (AFAIK). Changing this would break a lot of games that use this as a means to differentiate between testing and live sessions.

edit: welp

1 Like

This does seem like a bug - testing in Studio should be the same as testing online as much as possible.

I’ll file a ticket internally for us to fix this.

11 Likes

I’m okay with them fixing this and breaking those games. It’d be one thing if they were using Game. Job ID, but Creator ID is a super hacky work around. We have run service methods to check which environment a script is running in, so this would likely be old games anyway.

if anyone’s game is using Creator ID or job ID, they should switch to run service.

9 Likes

Apparently this was supposed to be solved years ago, but the issue has not been fixed. Any news on when this will happen?

Screen Shot 2020-04-17 at 12.00.28 AM

5 Likes

Bumping this again, its not a massive problem but I would like for this to work.

Also about this I’m creating a playerlist so I’m trying to detect whether a player is the owner not the specific client.

2 Likes

Sorry for necroposting, but I think I’ve got a decent solution: put a RemoteFunction(name it getCreatorId) and a script inside your localscript. In the script put:

script.Parent.getCreatorId.OnServerInvoke = function()
	return game.CreatorId
end

When you try something similar to this in the local script:

print(script.getCreatorId:InvokeServer())

The output will be your creatorid. Again, sorry for necroposting.

Why is this still a problem? It’s been half a decade

3 Likes

This issue is still occurring.

Bumping, this shouldn’t happen as developers may be confused when it outputs differently between in-game and in-studio. Consistency between Studio and the client is a huge must

still happening. even when running it on a server script, it still returns 0 in roblox studio (although refreshing the place fixes it, which i find quite odd tbh)

This is still broken at this time.

when your admin scripts use game.CreatorId, rip can’t test admin unless ranking urself by going to server, then change the int value data

1 Like

I know about the fact that it says 0. But I never saw this as a bug.

If your game is not published, it’s 0. A unpublished game doesn’t have a CreatorId.

If your game is published it will not be 0. A published game has a owner which is put in the CreatorId.

 

Player 0 is

image

something you can bring if you run game.Players:CreateLocalPlayer()

 

This player also appears like so

image

That’s the Server’s Player right now.

If the CreatorId is 0, it’s because the game is unpublished.

if you want to test CreatorId, then publish the game. The CreatorId is meta information for published games

 

if a published game ever shows CreatorId 0, then it’s an issue

Aiming to get the fix for this in for the next release - sorry for the long wait!

3 Likes

Update: the fix for this should be live now on the latest Studio release - thanks for the report!

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.