PromptGamePassPurchase bringing failed menu

Trying to make a VIP gamepass, When I test buy it it brings this menu up
gggggg
I am actually so confused
Script:

local Market_Place = game:GetService("MarketplaceService")
game.ReplicatedStorage.Events.Server_Events.Purchase_Vip.OnServerEvent:Connect(function(Player)
	Market_Place:PromptGamePassPurchase(Player, 6372308532)
end)

Hello SpaceMan!

Are you sure that the Player argument you are passing through to the function is a player?
Btw, here’s a cleaner version of your code:

local MPS = game:GetService("MarketplaceService")
local RSE = game:GetService("ReplicatedStorage")
local Events = RSE.Events

Events.Server_Events.Purchase_Vip.OnServerEvent:Connect(function(Player)
	Market_Place:PromptGamePassPurchase(Player, 6372308532)
end)

Kind Regards,
Bellamy Lakey.

I get an error
“Unable to cast value to object”

Which line, could you provide a screenshot?
Also could you double check that it is the correct ID.

That’s because they are wrong. PromptGamePassPurchase takes the player, NOT the UserId.
Are you using the right gamepassID?

Yeah I just realized after going to the docs

memee
updated script:

local Market_Place = game:GetService("MarketplaceService")
game.ReplicatedStorage.Events.Server_Events.Purchase_Vip.OnServerEvent:Connect(function(Player)
	Market_Place:PromptGamePassPurchase(Player.UserId, 6372308532)
end)

I have checked, I can check again

I am 100% certain that the Player argument inside your function does not return a player.

Send me the code that is firing your Event.

local Player = game.Players.LocalPlayer
local MarketPlace = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage:WaitForChild("Events").Server_Events.Purchase_Vip:FireServer(
		{
		Type = MarketPlace.PromptGamePassPurchase, ID = "6372308532"
		}
	)
end)

You are not sending the player argument to the server at all.

You don’t need to, the server automatically receives the player as its first parameter.

thought to myself “im gonna use this” never used it

Alright Spaceman, try this.

Local Script:

local Player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage:WaitForChild("Events")

script.Parent.MouseButton1Click:Connect(function()
    Events.Server_Events.Purchase_Vip:FireServer(6372308532)
end)

Server Script:

local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage:WaitForChild("Events")

Events.Server_Events.Purchase_Vip.OnServerEvent:Connect(function(Player, gamePassID)
    MarketplaceService:PromptGamePassPurchase(Player, gamePassID)
end)

(I did 1 edit, feel free to use the little improved code by copy pasting again)
Aaaaand just double check your GamePassID again so it is valid.

The reason your code didn’t work is because you passed a table to where the GamePassID argument has to be.

I agree with @Uzixt, your gamepass id probably isn’t valid. Did you make a gamepass for your game in the Creator Hub yet?

i get this
ggadsadawsd

You’re most definitely using the wrong Id. Try the Id 898114248 (I found it on your account, it’s probably the game pass you’re trying to use)

1 Like

Could you add some prints to your server code?

local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage:WaitForChild("Events")

Events.Server_Events.Purchase_Vip.OnServerEvent:Connect(function(Player, gamePassID)
    print(Player.Name)
    print(gamePassID)
    MarketplaceService:PromptGamePassPurchase(Player, gamePassID)
end)