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

Rainbow Magic carpet GamePass?

Asked by 3 years ago

It works if you don't own gamepass but if you own gamepass and join you don't have it in backpack I was doing this in studio

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local MagicCarpet = ReplicatedStorage:WaitForChild("GamePassItems"):WaitForChild("RainbowMagicCarpet")
local gamepass_id = 10008706

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function()
        MPS:UserOwnsGamePassAsync(player.UserId, gamepass_id)
    end)
end)

MPS.PromptGamePassPurchaseFinished:Connect(function(Player, gamepass_id, isPurchased)
    if isPurchased == true then
    MagicCarpet:Clone().Parent = Player.Backpack
    elseif isPurchased == false then
    print("Player did not purchase game pass!")
    end
end)

1 answer

Log in to vote
1
Answered by 3 years ago

you would check with MarketPlaceService:UserOwnsGamePassAsync the code in MarketPlaceService.PromptGamePassPurchaseFinished seems like it could do the job for player.CharacterAdded, just set "isPurchased" with MarketPlaceService:UserOwnsGamePassAsync

for example:

player.CharacterAdded:Connect(function()
    local isPurchased = MPS:UserOwnsGamePassAsync(player.UserId, gamepass_id);
    if isPurchased then
        MagicCarpet:Clone().Parent = Player.Backpack
    else
        print("Player does not own game pass!")
    end
end)

also i would recommend this gamepass stuff be in a server script rather than a LocalScript as if it were in the latter nobody would see the carpet

0
I have it in a server script and I did like you said and I get this error 14:03:13.164 - ServerScriptService.Script:8: attempt to index nil with 'CharacterAdded' thestorm2897 10 — 3y
Ad

Answer this question