Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a script where it checks if the player is the owner of the game?

Is there any way to do this or any alternative?

2 comments

0

yes

0

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

2 answers

✓ Accepted answer

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

0

thats for a group i think he/ she wants it for the game

0

No it's not. That will get the owner even if it's a group.

0

In other words, it works for all games.

0

isnt my way eaiser thoughif game.Players.LocalPlayer.UserId == game.CreatorId then -- do what ever you want end

0

Easier, yes. Significantly more insecure, also yes.

0

Desperate boy here

0

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