The reason i'm making this is for future reference.
GOAL: I'm trying to make these parts prompt me when i step on them.
ERROR: It's not prompting me or saying that i already have the gamepass.
If you read these steps, it should be easy to answer my question
My script may be horribly formatted, but lets give it a try :)
ME: "Mom can we have a script at home"
MOM "We already have a script at home"
The Script:
local MarketPlaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local HasPass = false local PromptSpeed = game.Workspace:WaitForChild("PromptSpeed") local PromptBox = game.Workspace:WaitForChild("PromptPart") local PromptPower = game.Workspace:WaitForChild("PromptJump") local PromptVip = game.Workspace:WaitForChild("PromptVIP") local function OnPromptPurchase(player, gamepassId) player = Players.LocalPlayer local sucess, errormessage = pcall(function() HasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) if HasPass then print("Player has gamepass") end if not HasPass then PromptSpeed.Touched:Connect(function() MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8638546)) end) if not HasPass then PromptBox.Touched:Connect(function() MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8582273)) end) if not HasPass then PromptPower.Touched:Connect(function() MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8796152)) end) if not HasPass then PromptVip.Touched:Connect(function() MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8757181)) end) end end end end end) end
Sorry for the joke in the beginning, it was just to keep you guys entertained :)
Code below will promt the purchase id to player. Change the player to the player instance you want to prompt purchase of id, which could be e.g a gamepass.
game:GetService("MarketplaceService"):PromptPurchase(player, id)
Here's my finish result thanks to AspectW!
local MarketPlaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local HasPass = false local PromptSpeed = game.Workspace:WaitForChild("PromptSpeed") local PromptBox = game.Workspace:WaitForChild("PromptPart") local PromptPower = game.Workspace:WaitForChild("PromptJump") local PromptVip = game.Workspace:WaitForChild("PromptVIP") local function OnPromptPurchase(player, gamepassId) player = Players.LocalPlayer local sucess, errormessage = pcall(function() HasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) if HasPass then return end if not HasPass then PromptSpeed.Touched:Connect(function(player) MarketPlaceService:PromptGamePassPurchase(player, 8638546) end) if not HasPass then PromptBox.Touched:Connect(function(player) MarketPlaceService:PromptGamePassPurchase(player, 8582273) end) if not HasPass then PromptPower.Touched:Connect(function(player) MarketPlaceService:PromptGamePassPurchase(player, 8796152) end) if not HasPass then PromptVip.Touched:Connect(function(player) MarketPlaceService:PromptGamePassPurchase(player, 8757181) end) end end end end end) end