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

Can someone help me for a object wich does not remain in inventory?

Asked by 1 year ago

Hi! I am creating a game wih gamepasses. I have created a shop and I have putted the gampasses I want in. The problem is when I buy a gamepass (for example a speedcoil), I have the object but when I dead, and I respawn, I dont keep the object in my inventory. Theres the script:

local MarketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")

local gravitycoilgamepassID = 100531781
local speedcoilgamepassID = 100523532

game.Players.PlayerAdded:Connect(function(player)

    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, speedcoilgamepassID)
    end)

    if hasPass then
        print("player has the game pass")

        local speedcoil = game.ReplicatedStorage["SpeedCoil"]:Clone()
        speedcoil.Parent = player.Backpack
    end
end)

local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)

    if purchaseSuccess ==  true and purchasedPassID == speedcoilgamepassID then
        print(player.Name .. " purchased the speed coil game pass!")

        local speedcoil = game.ReplicatedStorage["SpeedCoil"]:Clone()
        speedcoil.Parent = player.Backpack
    end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)

Thanks in advance! Have a nice day!

1 answer

Log in to vote
1
Answered by 1 year ago

Hi issue with your script is that it activates when someone buys gamepass. An easy way to fix this issue would be to make a datastore. If needed here is a video on that Tutorial Hope this helps!!

0
Its work but now I have the objects although I did not buy them. wDaerkfeX 37 — 1y
0
Ok your going to want to make sure the player doesn't start with them theking66hayday 841 — 1y
0
And make sure the part where it gives u the tool for free to remove theking66hayday 841 — 1y
0
Also u may want to test it on a different account and see how it works, because it got datastore theking66hayday 841 — 1y
Ad

Answer this question