Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

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

2 answers

✓ Accepted answer

(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)

1 comment

0

Yep works like needed ty!

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

3 comments

0

Its short, but sweet

0

hey copy my script about prompt the gamepass its cool

0

alright

This discussion is preserved as it was. New answers, comments, and votes are closed.