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

Everytime you press the button in prompts the gamepass purchase, how to fix?

Asked by 3 years ago

I just want the button (textbutton) to check if you own the gamepass, if you do it gives you the perks, if you dont only then it prompts to purchase the gamepass. I tried fixing it on my own and know it must not be that hard but it didnt work.

local player = script.Parent.Parent.Parent.Parent
local button = script.Parent
local MarketServicePlace = game:GetService("MarketplaceService")
local id = 18020349

script.Parent.MouseButton1Click:Connect(function()
    game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)

    game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,id) == true then
            player.Character.Humanoid.HeadScale.Value = 0.35
            player.Character.Humanoid.BodyDepthScale.Value = 0.35
            player.Character.Humanoid.BodyWidthScale.Value = 0.35
            player.Character.Humanoid.BodyHeightScale.Value = 0.35
            player.Character.Humanoid.WalkSpeed = 30
            player.Character.Humanoid.JumpPower = 500

        end
    end)
end)

0
Also if someone could help me that when you press the button after you shrinked that you grow back normally, would be amazing :D jorrelnootje 12 — 3y

2 answers

Log in to vote
1
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

(I am not sure if this works, but I hope it does, I changed the if statement to the parameter of Purchased and made it if Purchased == true then or something)

I think this is what you wanted, you need to buy the gamepass and click again to make it work, if you want something better than contact me, I might help, this script is a complete rush

local player = game:GetService("Players").LocalPlayer
local button = script.Parent
local MarketServicePlace = game:GetService("MarketplaceService")
local id = 18020349

script.Parent.MouseButton1Click:Connect(function()
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) == true then
        -- do thing you want
    else
        game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
    end)
end)
0
Yep works like needed ty! jorrelnootje 12 — 3y
Ad
Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
3 years ago
Edited 3 years ago

To check if someone has the gamepass, you do the following

local MarketPlaceService = game:GetService("MarketPlaceService ")

local PlayerBoughtThisGamePass =  MarketPlaceService.UserOwnsGamePassAsync(Userid, GamePassiD)

if PlayerBoughtThisGamePass then
  print("Player Has Bought This GamePass")

else 

--prompt the game pass, idk how to do that
end
0
Its short, but sweet Xyternal 247 — 3y
0
hey copy my script about prompt the gamepass its cool Xapelize 2658 — 3y
0
alright Xyternal 247 — 3y

Answer this question