#How to successfully listen for when a player prompted finishes his decision of buying the gamepass

32 messages · Page 1 of 1 (latest)

gleaming crown
#
local plr = game.Players.LocalPlayer
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local MarketplaceService, Jump_PassID = game:GetService("MarketplaceService"), 122361084
repeat wait() until game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")

local Inputs = {
    Enum.KeyCode.Space
}

plr.Character.Humanoid.JumpPower = 0 -- Normal: 50

UserInputService.InputBegan:Connect(function(Input, GameProcessed)
    if not GameProcessed and (not plr:FindFirstChild("CanJump")) then
        if table.find(Inputs, Input.KeyCode) then
            MarketplaceService:PromptGamePassPurchase(plr, Jump_PassID)
            MarketplaceService.PromptGamePassPurchaseFinished:Connect(function()
                table.remove(Inputs)
                game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50
            end)
        end
    end
end)
#

Even if i press "Cancel" it still runs as a successful purchase

mild niche
#

you have to get their PurchaseDecision or something

gleaming crown
#

dont know how

dire depot
#

3rd returned value

#

wasPurchased

gleaming crown
#

ty

dire depot
#

Just add those to your anonymous function's parameter list

gleaming crown
dire depot
#

I think you scrolled to the wrong one..

gleaming crown
#

Kind of similar to me not understanding WasPurchased: boolean

dire depot
#
            MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)
                table.remove(Inputs)
                game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50
                if wasPurchased then
                  -- do stuff
                end
            end)
#

That means that value will be returned as a Boolean, true/false

#

Cancellations will return false

gleaming crown
# dire depot ```Lua MarketplaceService.PromptGamePassPurchaseFinished:Connect(fun...
local plr = game.Players.LocalPlayer
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local MarketplaceService, Jump_PassID = game:GetService("MarketplaceService"), 122361084
repeat wait() until game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")

local Inputs = {
    Enum.KeyCode.Space
}

plr.Character.Humanoid.JumpPower = 0 -- Normal: 50

UserInputService.InputBegan:Connect(function(Input, GameProcessed)
    if not GameProcessed and (not plr:FindFirstChild("CanJump")) then
        if table.find(Inputs, Input.KeyCode) then
            MarketplaceService:PromptGamePassPurchase(plr, Jump_PassID)
            MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(plr, Jump_PassID, WasPurchased)
                if WasPurchased then
                    table.remove(Inputs)
                    game.Players.LocalPlayer.Changed.Humanoid.JumpPower = 50
                end
            end)
        end
    end
end)
``` dont know where to continue from here
dire depot
#

whatdoyamean?

gleaming crown
#

Yes i suppose im dumb

dire depot
#

Nah, like was it not working?

gleaming crown
#

ill show in a sec

dire depot
gleaming crown
dire depot
#

game.Players.LocalPlayer.Changed.Humanoid.JumpPower = 50 Error points to this line. What looks wrong here?

#

(trying to reinforce principles of debugging)

pulsar elbow
#

oh my god

#

lmao

dire depot
gleaming crown
# hard umbra oml

Got it working but i got one for jump and walk and whenever u spam w/a/s/d/space(bar) then canel it will complete as a success