#NEED HELP WITH GAMEPASS

1 messages · Page 1 of 1 (latest)

granite basin
#

Explanation in comments

#
local UnlockIndex = game.ReplicatedStorage.UnlockIndex
local MarketplaceService = game:GetService("MarketplaceService")

local function onPlayerAdded(Player)
    local success, OwnsAsset =
        pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, Player, 1730820105)
    if not success then
        local errorMessage = OwnsAsset
        warn("Error Code: 4")
        return
    end

    if OwnsAsset then
        UnlockIndex:FireClient(Player, "Shiny")
        local Character = Player.Character or Player.CharacterAdded:Wait()
        if Character then
            Character:WaitForChild("HumanoidRootPart"):WaitForChild("TagUI").Vip.Visible = true
        end
        print(Player.Name.. " owns VIP.")
    else
        print(Player.Name.." does not own VIP.")
    end
end

Players.PlayerAdded:Connect(onPlayerAdded)```
long copper
#

?

granite basin
#

I made this server script that should check if the player owns a gamepass and fire [equip] and make one thing visible. The problem is it says i dont own the gamepass even if i do

#

basically prints "does not own VIP."

#

i, as the creator of the gamepass should own it automatically right?

#

so it should instantly count me as a VIP

viral coral
#

I quickly searched and it says that you do not automaticly own them

#

and that you'd have to purchase them.

#

But i think in studio testing you can purchase gamepasses for free

granite basin
#

not liek i dont have robux for that but still

#

cuz it checks only when playeradded

viral coral
#

then check after you purchase

granite basin
viral coral
granite basin
#

how do i do that

viral coral
#

if you prompt a purchase in studios it should be for free

granite basin
#

idk how i check if the player just bought it

#

yes

#

but how do i check

#

with what

viral coral
#

by checking if they own the gamepass like you did on join

granite basin
#

yes but how do i know they just purchased it

#

like ik how to check if they own it

#

but i dont know when they purchase the thing

viral coral
granite basin
#

wait

#
    MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
end)```
#

so after the promptgamepasspurchast?

viral coral
#

yeah

#

then just check if they bought it

#

on the server tho

granite basin
granite basin
#

wait no it has to be remote event

viral coral
viral coral
granite basin
#

idk why but it marks it red

#
    MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
    PurchasedVIP:FireServer()
end)```
#
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UnlockIndex = ReplicatedStorage.UnlockIndex
local PurchasedVIP = ReplicatedStorage.PurchasedVIP
local MarketplaceService = game:GetService("MarketplaceService")

local function PlayerOwnsVIP(Player)
    local success, OwnsAsset =
        pcall(MarketplaceService.PlayerOwnsAssetAsync, MarketplaceService, Player, 1730820105)
    if not success then
        local errorMessage = OwnsAsset
        warn("Error Code: 4")
        return
    end

    if OwnsAsset then
        UnlockIndex:FireClient(Player, "Shiny")
        local Character = Player.Character or Player.CharacterAdded:Wait()
        if Character then
            Character:WaitForChild("HumanoidRootPart"):WaitForChild("TagUI").Vip.Visible = true
        end
        print(Player.Name.. " owns VIP.")
    else
        print(Player.Name.." does not own VIP.")
    end
end

PurchasedVIP:OnServerEvent:Connect(function(Player)
    PlayerOwnsVIP(Player)
end)

Players.PlayerAdded:Connect(PlayerOwnsVIP)```
#

@viral coral

viral coral
granite basin
viral coral
#

bruh

#

its PurchasedVIP.OnServerEvent:Connect()

#

Not ```
PurchasedVIP:OnServerEvent:Connect()

granite basin
#

oh

granite basin
#

@viral coral

viral coral
#

It looks like a event that fires when a purchase for a game pass is finished

granite basin
#

ok

#
    MarketplaceService:PromptGamePassPurchase(Player, GamepassID)
    if MarketplaceService:PromptGamepassPurchaseFinished(Player, GamepassID) then
        PurchasedVIP:FireServer()
    end
end)```
#

like this?

#

@viral coral

viral coral
#

and you need to listen to it on the server

granite basin
#

oh

granite basin
viral coral
#

OnServerEvent is a event not a method

granite basin
#

wait no

#

pcall(MarketplaceService:PlayerOwnsAssetAsync(Player, 1730820105))

#

this has :

viral coral
#

yeah that might be a method

#

Anyways i gotta go now. Just try reading through the MarketPlaceService docs or try to watch a tutorial i'll be gone for maybe 40 min or even till tomorrow

granite basin
#

ok

#

MarketPlaceService::PlayerOwnsAsset failed because HTTP 400

granite basin
granite basin
#

@viral coral got time?

viral coral
granite basin
viral coral
viral coral
#

Because after the first Parameter the pcall function expects a Tuple (More parameters) for the given function in the first parameter

granite basin
#
    local success, OwnsAsset = pcall(MarketplaceService:PlayerOwnsAssetAsync, Player, 1730820105)
    if not success then
        local errorMessage = OwnsAsset
        warn("Error Code: 4")
        return
    end

    if OwnsAsset then
        UnlockIndex:FireClient(Player, "Shiny")
        local Character = Player.Character or Player.CharacterAdded:Wait()
        if Character then
            Character:WaitForChild("HumanoidRootPart"):WaitForChild("TagUI").Vip.Visible = true
        end
        print(Player.Name.. " owns VIP.")
    else
        print(Player.Name.." does not own VIP.")
    end
end

Players.PlayerAdded:Connect(onPlayerAdded)
#

doesnt work

#

i think you forgor Mareketplace:PlayerOwnsAssetAsync**()**

#

also error: argument 2 missing or nil

#

@viral coral

viral coral
granite basin