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

How to make Server Lock Script (Gamepass)?

Id like to make a script that would allow people (that have a certain game-pass) to enter a game with no hassle. But kick any player that trys to join that doesn't have the game-pass. How would one start?

1 answer

You can check if the player owns a certain gamepass through the event UserOwnsGamepassAsync from MarketPlaceService.

With that being said you can just make a PlayerAdded event that gives the player, and check if the player owns the specified gamepass he should have, if not then Kick the player from the game.

Your script should look like this:

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local MarketPlaceService = game:GetService("MarketplaceService")
	local GamepassID = ID -- Put your gamepass ID
	
	if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) == false then -- If player does not own the gamepass
		Player:Kick("Reason") -- Kick the player with the specified reason.
	end
end)

Hopefully this solved your issue! Make sure to read more about MarketPlaceService as It'll definitely help you.

This discussion is preserved as it was. New answers, comments, and votes are closed.