#Gamepass

27 messages · Page 1 of 1 (latest)

tardy yarrow
#

Does anyone know how to make people keep their gamepasses when they reset/respawn or rejoin the game as rn if they buy it and die they lose the item (eg gravity coil)

#

this is the main script to buy the coil

local mps = game:GetService("MarketplaceService")
local gravitycoilId = script.GamepassID.Value

mps.PromptGamePassPurchaseFinished:Connect(function(plr,passId,purchased)
    if purchased and passId == gravitycoilId then 
        script.GravityCoil:Clone().Parent = plr.Backpack
    end
end)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function()
        local ownsPass = mps:UserOwnsGamePassAsync(plr.UserId,gravitycoilId)
        if ownsPass then
            script.GravityCoil:Clone().Parent = plr.Backpack
        end
    end)
end)```
unique radish
tardy yarrow
#

improved it but stuck on a new line

local GravityCoilGamepassID = 633104403
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        local success, message = pcall(function()
            hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GravityCoilGamepassID)
        end)
        if hasPass then
            print(player.Name.." has the gamepass")
            local clone = game:GetService("MarketplaceService"):GravityCoilGamepassID():GetChildren()[1]
            clone.Handle.Anchored = false
            clone.Parent = player.Backpack
        else
            print(player.Name .. " does not have the gamepass")
        end
    end)
end)


local function onPromptGamePassPurchaseFinished(player, purchasedPassId, purchaseSuccess)
    if purchaseSuccess and purchasedPassId == GravityCoilGamepassID then
        print(player.Name.. " has purchased the gamepass.")
        local clone = game:GetService("MarketplaceService"):GravityCoilGamepassID():GetChildren()[1]
        clone.Handle.Anchored = false
        clone.Parent = player.Backpack
    end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)```
#

everything works the way I want it to apart from the GetService in local clone = , not sure how to make it work trying to figure it out as I found this fix in another thread on how to fix the issue im having but I cant get it to work without something bugging out

unique radish
tardy yarrow
unique radish
#

this part of this line is just a big no

tardy yarrow
#

yeah trying to find what I'm meant to use for it but I cant find what service is needed or if I can replace the whole getservice idea as a whole to make it work

#

that was just the last idea I had since substituted a few different things into that before it

unique radish
#

the clone should just be

local clone = (Dotnav to gravityCoil (preferably in RS)):Clone()
tardy yarrow
fluid sapphireBOT
#

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

unique radish
tardy yarrow
#

the script is in the tool so if they get given the tool it should work from what I understand

unique radish
#
local clone = script.GravityCoil:Clone()
tardy yarrow
unique radish
#

you need to handle the receipt before it counts I think

tardy yarrow
unique radish
#

it's a tad more difficult

tardy yarrow
#

or would I have to use something like this ? local playerProductKey = receiptInfo.PlayerId .. ':' .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync( playerProductKey ) then return Enum.ProductPurchaseDecision.PurchaseGranted

tardy yarrow
#

idk how others get it to work then without all this extra stuff , someone mentioned something about using starterpack but I think it would just give it to anyone who joined rather than those who bought it using that