so when I was trying to detect the creatorID of the game, using the command game.CreatorId
and i get a 6 digit number instead of my UserID which is 9 digit
which is quite confusing because the api says that CreatorId returns the UserId. Can anyone tell me why? thanks
Can you show us your script for reference?
Here is an example from the DevHub for a “Met the creator” badge, it could help:
local BadgeService = game:GetService("BadgeService")
local Players = game:GetService("Players")
-- change these
local OWNER_ID = 212423 -- can use game.CreatorId for published places
local BADGE_ID = 1
local ownerInGame = false
local function playerAdded(newPlayer)
if newPlayer.UserId == OWNER_ID then
-- if new player is the owner, set ownerInGame to true and give everyone the badge
ownerInGame = true
for _, player in pairs(Players:GetPlayers()) do
-- don't award the owner
if player ~= newPlayer then
BadgeService:AwardBadge(player.UserId, BADGE_ID)
end
end
elseif ownerInGame then
-- if the owner is in the game, award the badge
BadgeService:AwardBadge(newPlayer.UserId, BADGE_ID)
end
end
local function playerRemoving(oldPlayer)
if oldPlayer.UserId == OWNER_ID then
-- set ownerInGame to false
ownerInGame = false
end
end
-- listen for players joining and leaving
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerRemoving:Connect(playerRemoving)
-- fire playerAdded for existing players
for _, player in pairs(Players:GetPlayers()) do
playerAdded(player)
end
As you can see, the CreatorId gives 6 digits here
↓↓↓
i just ran two commands
print(game.CreatorId)
print(game.Players.KmbAV72.UserId)
Which results in two answers, but according to the API i think it should output my userid as I published the game
I got a 9 digit number(the one you can find in the URL of your profile) for UserId
While getting the 6 digit number(don’t know where that came from) for CreatorId
I’m not entirely sure why does the creator ID returns a 6 digit code; however, it shouldn’t represent any problem since that same thing happens in the example from the DevHub that I posted above. Try to do wathever you want with it and then look for errors
This isn’t the solution but make sure you also test to see if the game owner is a user and not a group, you can do this with the following code:
if game.CreatorType == Enum.CreatorType.User then
--Your code here...
end
I tested printing the creator ID in studio and it came up with 0, I tested it in the same game but not in studio and it works, try testing it in the actual game if you haven’t already.
Hoped this helped
This comparation works even if game.CreatorId returns 6 digit code.
if game:GetService("Players"):WaitForChild("KmbAV72").UserId == game.CreatorId then
print("Player KmbAV72 a is game creator.")
end
yes i know that, but i am just wondering why
game.CreatorId is the ID of the game’s owner. If the game is group-owned, then the CreatorId will be the ID of the group. If the game is owned by an individual user, the CreatorId will be the ID of that user. In your case, the game is group-owned; therefore, the CreatorId is the ID of the group. Regardless of the group owner, the CreatorId for the group’s game will always be the ID of the group.