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

Gamepass doesn't prompt after being killed when the player touched the gamepass door again. Help?

Asked by
xp5u 25
2 years ago
local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")


local mps = game:GetService("MarketplaceService")

local gamepassID = 18133269


local gamepassOwned = false

pcall(function()

    gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)


if gamepassOwned == true then

    workspace.GamepassDoor2.Transparency = 1
    workspace.GamepassDoor2.CanCollide = false
end


humanoid.Touched:Connect(function(touchedPart)

    if gamepassOwned == true then return end


    if touchedPart == workspace.GamepassDoor2 then


        mps:PromptGamePassPurchase(plr, gamepassID)
    end
end)


mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)

    if not purchaseSuccess then return end

    if playerPurchased == plr and purchasedID == gamepassID then


        gamepassOwned = true


        workspace.GamepassDoor2.Transparency = 1
        workspace.GamepassDoor2.CanCollide = false
    end
end)

it is a localscript in starterplayerscripts

1 answer

Log in to vote
1
Answered by
CDXKIE 130
2 years ago

I haven't tested this, but you should try putting the code to open the door in a while wait(0.2) do loop. It might be because the code is only running once, and it resets when the player dies?

0
alright, where should I put this? xp5u 25 — 2y
0
pretty sure just at the bottom of your script. CDXKIE 130 — 2y
Ad

Answer this question