I'm simply wondering how to check if a player has a game pass and if not prompt a purchase. I tried making my own script, although I am not sure why it isn't working. Help would be very much appreciated!
wantedtrail = nil script.Parent.MouseButton1Click:Connect(function() if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId, 5794064) then wantedtrail = "RedTrail" workspace.Events.Trail:FireServer(wantedtrail) else game:GetService("MarketplaceService"):PromptGamePassPurchase(player, 5794064) end end)
First of all, you never define player
and second you use UserOwnsGamePassAsync
for this, not UserOwnsAsset
that is for things that are in the library/catalog.
local player = game.Players.LocalPlayer wantedtrail = nil script.Parent.MouseButton1Click:Connect(function() if game:GetService("MarketplaceService"):PlayerOwnsGamePassAsync(player, 5794064) then wantedtrail = "RedTrail" workspace.Events.Trail:FireServer(wantedtrail) else game:GetService("MarketplaceService"):PromptGamePassPurchase(player, 5794064) end end)
If this does not work, remember use a local script