Is there any way to do this or any alternative?
How do I make a script where it checks if the player is the owner of the game?
2 answers
This can be done using the CreatorId and CreatorType property of the DataModel (Game). We can use CreatorType to check if it is owned by a group, if it is and the player is rank 255 in the group then they are the owner. If it's owned by a user we can simply compare the UserIds. The code is below: (If the game is owned by a group it will only work in game)
function IsPlayerOwner(plr) -- Pass the player object
if game.CreatorType == Enum.CreatorType.User then
return plr.UserId == game.CreatorId or nil
else
return plr:GetRankInGroup(game.CreatorId) == 255 or nil
end
end
I hope my answer solved your problem, if it did make sure to mark it correct!
7 comments
thats for a group i think he/ she wants it for the game
No it's not. That will get the owner even if it's a group.
In other words, it works for all games.
isnt my way eaiser thoughif game.Players.LocalPlayer.UserId == game.CreatorId then -- do what ever you want end
Easier, yes. Significantly more insecure, also yes.
Desperate boy here
@incapaz Downvotes are used to signal that an answer isn't good or doesn't work. Don't abuse down votes because you're angry with me personally.
this has to be in a local script but here
if game.Players.LocalPlayer.UserId == game.CreatorId then
-- do what ever you want
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
yes
Well um, can you tell me how to do it?