Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make Server Lock Script (Gamepass)? [closed]

Asked by 5 years ago

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?

Closed as Not Constructive by DinozCreates, xPolarium, and theking48989987

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Isaque232 171
5 years ago

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.

Ad