Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

PlayerOwnsGamepassAsync is not a valid member of MarketplaceService?

Asked by 5 years ago

what is wrong here? trying to fix a tycoon kit script, the original was PlayerOwnsAsset and now gps arent assets heres that one thing of code, pls help idk whats wrong btw im new to scripting so dont rek me

            v.Head.Touched:connect(function(hit)
             local player = game.Players:GetPlayerFromCharacter(hit.Parent)
                if v.Head.CanCollide == true then
                    if player ~= nil then
                        if script.Parent.Owner.Value == player then
                            if hit.Parent:FindFirstChild("Humanoid") then
                                if hit.Parent.Humanoid.Health > 0 then
                                    local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
                                    if PlayerStats ~= nil then
                                        if (v:FindFirstChild('Gamepass')) and (v.Gamepass.Value >= 1) then
                                            if game:GetService("MarketplaceService"):PlayerOwnsGamepassAsync(player,v.Gamepass.Value) then
                                                Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
                                            else
                                                game:GetService('MarketplaceService'):PromptPurchase(player,v.Gamepass.Value)
                                            end
                                        elseif (v:FindFirstChild('DevProduct')) and (v.DevProduct.Value >= 1) then
                                            game:GetService('MarketplaceService'):PromptProductPurchase(player,v.DevProduct.Value)
                                        elseif PlayerStats.Value >= v.Price.Value then
                                            Purchase({[1] = v.Price.Value,[2] = v,[3] = PlayerStats})
                                            Sound(v, Settings.Sounds.Purchase)
                                        else
                                            Sound(v, Settings.Sounds.ErrorBuy)
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end)
            end
        end)
    end

1 answer

Log in to vote
0
Answered by
popeeyy 493 Moderation Voter
5 years ago

There are two problems with your code.

First of all, it's UserOwnsGamePassAsync, not player, and with a capital G. You should use it like this.

game:GetService('MarketplaceService'):UserOwnsGamePassAsync(player.UserId, v.Gamepass.Value)

Also, as shown in above, you need to provide the UserId instead of the player object for UserOwnsGamePassAsync.

0
TYSM dude <333333 InfiniteWhileLoop 19 — 5y
Ad

Answer this question