Gamepass Purchase

Don’t use local scripts for proximity if its in side of workspace.

No, no… you got it all wrong… its the opposite way… you should be firing to the client

What how when ehhh bruh my brain

To fire to client, you use: FireClient(Player) and use a local script to get that event, OnClientEvent()

ok Will This Work:

Server Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VIPEvent = ReplicatedStorage.Events.VIPEvent
local vipRoom = game.Workspace.Scripts["VIP-Room"]
local proxy = vipRoom.Buy.ProximityPrompt

proxy.Triggered:Connect(function(player)
	VIPEvent:FireClient()
end)

Local Script

local mps = game:GetService("MarketplaceService")
local vipRoom = game.Workspace.Scripts["VIP-Room"]
local proxy = vipRoom.Buy.ProximityPrompt
local purchaseSound = game.SoundService.purchase
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VIPEvent = ReplicatedStorage.Events.VIPEvent

local Product = 145084410

VIPEvent.OnClientEvent:Connect(function(player)
	if mps:PlayerOwnsAsset(player, Product) then
		vipRoom:Destroy()
		purchaseSound:Play()
	else
	end
end)

No, you forgot to put player in fireclient()

SERVER

local proxy = vipRoom.Buy.ProximityPrompt
local mps = game:GetService("MarketplaceService")
local purchaseSound = game.SoundService.purchase
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Product = 145084410
local VIPEvent = ReplicatedStorage.Events.VIPEvent
proxy.Triggered:Connect(function(plr)
   if mps:PlayerOwnsAsset(plr,Product) then
       VIPEvent:FireClient(plr)
       purchaseSound:Play()
  else
      mps:PromptGamePassPurchase(plr,Product)
   end
end)

CLIENT

local vipRoom = game.Workspace.Scripts["VIP-Room"]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VIPEvent = ReplicatedStorage.Events.VIPEvent
VIPEvent.OnClientEvent:Connect(function(plr)
   vipRoom:Destroy()
end)

Why do I need This?

VIPEvent:FireClient()

To fire the OnClientEvent so that the part is destoryed locally for the player (This means only 1 player can o into vip room if they have gamepass not for server)

To destroy the VIP part on the client… thats what you want

I used this, but I edited it.

Here are my scripts:

Server:

local mps = game:GetService("MarketplaceService")
local vipRoom = game.Workspace.Scripts["VIP-Room"]
local proxy = vipRoom.Buy.ProximityPrompt
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VIPEvent = ReplicatedStorage.Events.VIPEvent

local Product = 145084410

proxy.Triggered:Connect(function(plr)
	if mps:PlayerOwnsAsset(plr,Product) then
		VIPEvent:FireClient(plr)
	else
		mps:PromptGamePassPurchase(plr,Product)
	end
end)

Local:

local vipRoom = game.Workspace.Scripts["VIP-Room"]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VIPEvent = ReplicatedStorage.Events.VIPEvent
local purchaseSound = game.SoundService.purchase

VIPEvent.OnClientEvent:Connect(function(plr)
	vipRoom:Destroy()
	purchaseSound:Play()
end)

This actually does not give any errors, but it won’t open the door for me. Is it because I’m testing in the studio, or because when I buy the pass I can buy it again? It does not tell me that you already own it in studio.

Test it in the actual game, I’m not sure if it will work though

What the hell I don’t have that much Robux to test.

Its a gamepass not a dev product right? You already have this owned. Go in the actual game and try it

Its not my game its My friend’s Game :frowning:

Now i think thats the problem, get your friend to test it instead since they made it.

My friend is currently unavailable; I will try again tomorrow; if successful, I will provide you with a solution.

Thanks for your help.

Another thing is if you want the door to open after a player has purchased a gamepass. Put this in the Server Script under proximity script

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, pass_id, was_purchased)
       if product == pass_id and was_purchased then
           VIProom:FireClient(player)
       end
end)
1 Like

I advise you next time to mention that you don’t own this gamepass, however can you make your own gamepass in the game and use that product ID (it will be automatically owned if you made it)

okay, Thank you! This works. it’s was just the problem that it will not open after I purchase it.

1 Like