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).

11 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)