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