Requireing a Gamepass through a Script - ServerScriptStorage

Information

Hello Developers, I’m having some problems trying to figure out how I can make a Door or beriror with a ProximityPrompt to activate it. When the ProximityPromt is triggered, it get’s the Player’s ID and checks with they own the gamepass to go through the door. If they don’t, it will tween a Gui notification down telling the user that they don’t own they don’t own the gamepass and it will promt them to buy it. If they already own the gamepass, the ProximityPrompt and the Beriror is gone.

I have tried different Scripts of my own and looked at some Youtube Videos and DevForum threads similar to this. But all seem to not work or it’s outdated. How would I do this?

2 Likes

Make a part, put proximity prompt in it, put server script in it.

Make the script say

script.Parent.Triggered:Connect(function(player)
    print(player.UserId)
end)

That will print the player’s user id when they trigger it. To check if they have a gamepass, check out MarketplaceService and then if they have the gamepass, then do script.Parent.Parent:Destroy()

Edit: Actually, doing the above with the :Destroy() will destroy it for everyone, so you’ll need to make a LocalScript with part:Destroy() and then clone the localscript into the player’s PlayerGui.

2 Likes

Thanks for the information, I do know some things about MarketplaceService and the Triggered Event with ProximityPromt. I’m just looking for some ways or answers of how I can get what I said in the information to work. Thanks for the additional information tho!

1 Like

Oh sorry I didn’t read the whole thing. To send notif, do

game.StarterGui:SetCore("SendNotification", {Title = "You don't own that gamepass!", Text = "Sorry, you don't own this gamepass. Buy it if you want."}
Then to prompt it:
game:GetService("MarketplaceService"):PromptGamepassPurchase(player, gamepassID)
A way to find the player is through the prox. prompt:

1 Like

Probably check to see if they own it once the proximity prompt is triggered.

On the server:
If the player owns the gamepass:

  • fire a remote event that will toggle the .CanCollide boolean on the client.
    so maybe like a remoteevent:FireClient(player, true)

If the player does NOT own the gamepass:

  • do a remoteevent:FireClient(player, false) type thing I guess

Client:

local remote = game.ReplicatedStorage.RemoteEvent

remote.OnClientEvent:Connect(function(bool)
        if bool == true then
               --door access code here
         elseif bool == false then
               --denial code here (where the gui does its thing)
        end
end)

I hope this post helped. If you need for me to elaborate more on something or if you have any questions, reach out to me by replying to this post.

1 Like

I’ll check this out, thanks! I’ll be looking at the other post as well and trying them all out.

Alright, reach out to me if you have any questions, I will be checking this post in a couple hours. Hope this helps!!

I guess I’ll make your post the solution. I used varaibles and RemoteEvents how you kinda did it and it worked. I also got some of my friends to do it but for half of it they didn’t even know what I was talking about lmao.

You could perform the gamepass check on the door too (in a server script) and either let the player pass (do nothing if they have the gamepass) or kill the player (if they don’t have the gamepass).

That could also work as an alternative.
But if your looking for something more efficient, use my solution.