#Gamepass help

1 messages · Page 1 of 1 (latest)

left ether
#

If i buy the gamepass i get the item but if i die the item just deletes out of my backpack

code here:
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassID = 1652088332
local ToolName = "FlyingCarpet"
local carpetTemplate = script:WaitForChild(ToolName)

local function awardTool(player)
if not player.Backpack:FindFirstChild(ToolName) then
local carpetClone = carpetTemplate:Clone()
carpetClone.Parent = player.Backpack
end
end

Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local success, ownsGamepass = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UseId, gamepassID)
end)
if success and ownsGamepass then
awardTool(player)
end
end)
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchaseGamepassId, wasPurchased)
if purchaseGamepassId == gamepassID and wasPurchased then
awardTool(player)
end
end)

austere tartan
#

store it in a folder in like replicated storage

#

u can clone it first

left ether
#

ok

#

do i change the carpettemplate

austere tartan
#

nah its the same tool

misty edge
willow meteor
#

amateurs

misty edge
#

oh

#

that

#

my bad

#

LOL

#

well close enough at-least

left ether
#

o

#

where is startergear

austere tartan
#

idk

#

in game

#

at the bottom

left ether
#

i dont have it

austere tartan
#

nvm there isnt a startergear

#

yea

#

i go cofused

left ether
#

ppl tell me to put it in replicated

#

but it wont work

austere tartan
#

after u spawn u can parent it to the player

#

from replicated

left ether
#

can you rewrite the script

austere tartan
#

i will wait

misty edge
#

😭 😭

#

If i remember correctly, It's inside of the player instance

left ether
#

not anymore

#

imma crash out

#

ppl tell me to put it in replicated

#

but it WONT work

austere tartan
#
local Players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local itemsFolder = replicatedStorage:WaitForChild("Items")
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassID = 1652088332
local ToolName = "FlyingCarpet"
local carpetTemplate = script:WaitForChild(ToolName)

local function awardTool(player, chr)
    if not player.Backpack:FindFirstChild(ToolName) then
        local carpetClone = carpetTemplate:Clone()
        carpetClone.Parent = player.Backpack
        chr.Humanoid.Died:Connect(function()
            carpetClone.Parent = itemsFolder
        end)
    end
end

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if itemsFolder:FindFirstChild("carpetClone") then
            itemsFolder.carpetClone.Parent = player.Backpack
        end
        local success, ownsGamepass = pcall(function()
            return MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassID)
        end)
        if success and ownsGamepass then
            awardTool(player, character)
        end
    end)
end)

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchaseGamepassId, wasPurchased)
    if purchaseGamepassId == gamepassID and wasPurchased then
        awardTool(player)
    end
end)``` this might work u have to add a items folder in replicated storage
willow meteor
left ether
#

thx man