#Help to receive item when buying gamepass script

1 messages · Page 1 of 1 (latest)

formal blaze
#
(local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

local gear = ServerStorage.Gear 
local speedCoilPassId = 1725840688
local gravityCoilPassId = 1725460743
local rainbowCarpetPassId = 1728943252

game.Players.PlayerAdded:Connect(function(player)
    local success, ErrorMessage = pcall(function()
        if MarketplaceService:UserOwnsGamePassAsync(player.UserId, speedCoilPassId) then
            local speedCoil = gear.speedCoil:Clone()
            speedCoil.Parent = player.Backpack 
        end

        if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gravityCoilPassId) then
            local gravityCoil = gear.gravityCoil:Clone()
            gravityCoil.Parent = player.Backpack 
        end

        if MarketplaceService:UserOwnsGamePassAsync(player.UserId, rainbowCarpetPassId) then
            local rainbowCarpet = gear.rainbowCarpet:Clone() 
            rainbowCarpet.Parent = player.Backpack 
        end
    end)

    if not success then 
        warn(ErrorMessage)
    end
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, PassId, purchased)
    if purchased == false then 
        return
    end

    if PassId == speedCoilPassId then
        local speedCoil = gear.speedCoil:Clone()
        speedCoil.Parent = player.Backpack

    elseif PassId == gravityCoilPassId then
        local gravityCoil = gear.gravityCoil:Clone()
        gravityCoil.Parent = player.Backpack

    elseif PassId == rainbowCarpetPassId then
        local rainbowCarpet = gear.rainbowCarpet:Clone()
        rainbowCarpet.Parent = player.Backpack
    end
end)
)
#

Everytime i buy the gamepass i cant receive the items like the speed coil or gravity coil ect idk what else too do idek if its the script the problem or that i need another script for this

acoustic horizonBOT
#

studio** You are now Level 13! **studio

formal blaze
cedar ermine
formal blaze
#

im kinda new too scripting

cedar ermine
#

bruh

#

i dont think i need to explain

#

every 1st or 2nd part of any scripting tutorial series shows you how to use the output

#

I think you're lazy

formal blaze
#

yeah ill try watching how to find output

formal blaze
formal blaze
#

imma watch a output tutorial then come back

#

is output the thing that say execute command

acoustic horizonBOT
#

studio** You are now Level 1! **studio

formal blaze
#

or smt like that

#

nvm

#

i just watched a rlly old video

#

alr i found it

#

oh i found it

#

it says

#

nvm imma try to fix it myself

#

yeah i cant find it

#

21:17:36.762 Gear is not a valid member of ServerStorage "ServerStorage" - Server - Script:5 any idea how to fix this?

#

how do i make it valid

cedar ermine
formal blaze
#

Its my file

cedar ermine
formal blaze
cedar ermine
#

you mean folder?

formal blaze
#

yeah folder

cedar ermine
formal blaze
#

OHHH I UNDERSTAND MY MISTAKES NOW

#

the object in storage has to be the EXACT same as the ones in the script?

formal blaze
#

IT WORKS

#

THANK YOU SO MUCH

cedar ermine
#

i pointed out the ones you are refering to

formal blaze
#

yeah my objects names were different

cedar ermine
#

rainbow carpet may not work

formal blaze
#

from the ones in the script

#

rainbow carpet worked

cedar ermine
#

nice

formal blaze
#

alr i just need to know why when i buy speed coil my gravity coil gest bought too

#

i think i can fix that myself

cedar ermine
#

if you're at that level, I recommend you switch out PromptGamePassPurchaseFinished with ProcessReceipt

#

PromptGamePassPurchaseFinished is easily exploitable

formal blaze
#

wdym

cedar ermine
# formal blaze wdym
formal blaze
#

what are teh difference

acoustic horizonBOT
#

studio** You are now Level 2! **studio

cedar ermine
formal blaze
#

ok

#

i replace with UserOwnsGamePassAsync?

cedar ermine
#

thats why I said when you're at that level

formal blaze
#

ahhh ok ok

#

im just slowly learning rn ill maybe take ur advice and do that if i ever want to continue scripting in the future

formal blaze
#

Idk if ur still here but when i die i dont keep the item do u know how to keep it

formal blaze
#

alr

jagged belfry
#

I do use this event to implementing a yielding function. I realized I was using the isPurchased parameter

jagged belfry
#

I used the fact that ProcessReceipt and PromptGamePassPurchaseFinished are reliable

#

Instead of resuming the thread with isPurchased, I cached the thread and resumed it in the trusted pipelines

jagged belfry
#

I got employed with a studio that has its own framework, so I haven't had the opportunity to evolve my own tooling

cedar ermine
#

like in a scripting team

#

how is it

#

im too busy with school for a while, i dont got time to get experience 😭

jagged belfry
#

But it is profesionally engineered, so I know I can rely on it

cedar ermine
#

are u still a student

jagged belfry
cedar ermine
jagged belfry
cedar ermine
#

like ur in an outdoor school?

cedar ermine
#

a college student?

jagged belfry
cedar ermine
jagged belfry
cedar ermine
jagged belfry
#

Means the same thing 🤷‍♂️

cedar ermine
jagged belfry
cedar ermine
#

¯_(ツ)_/¯

#

take this to dms i have a fear of necro posting

jagged belfry
#

Nah, dumb conversation to keep going

#

I keep my DMs closed anyways

#

Good luck on getting into a studio though 💪

cedar ermine
#

you did not say that

cedar ermine
jagged belfry