Part not Turning Invisible when player buys gamepass

Ok so I’m trying to make a gamepass, and if you buy it, a part will go transparent. It doesn’t work, and there are no errors in script analysis or output. Also this is a child of the part, and a local script. Please call out any errors I made and have a great day!

local MPS = game:GetService("MarketplaceService")
local BindableEvent = game.ServerStorage.Event
local GamepassID = 10169496

script.Parent.Touched:Connect(function()
    MPS.PromptGamePassPurchaseFinished:Connect(function(Player, Id, Purchased)
   if Id == GamepassID and Purchased then
      script.Parent.Transparency = 1
      print("yay!")
   else
       print("Get noob!")
   end
end)
end)
1 Like

I believe PromptGamePassPurchaseFinished must not be inside the Touched event.

Then how would I know if the player bought the gamepass?

local MPS = game:GetService("MarketplaceService")
local BindableEvent = game.ServerStorage.Event
local GamepassID = 10169496

MPS.PromptGamePassPurchaseFinished:Connect(function(Player, Id, Purchased)
   if Id == GamepassID and Purchased then
      script.Parent.Transparency = 1
      print("yay!")
   else
       print("Get noob!")
   end
end)

Ok it used to print (get noob) but now it doesn’t print anything

If you wanna to check if player have gamepass use this

local MPS = game:GetService("MarketplaceService")
local BindableEvent = game.ServerStorage.Event
local GamepassID = 10169496

script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if MPS:UserOwnsGamePassAsync(plr.UserId,GamepassID) then
-- do stuff
end
end
end)

Error? 30charrrrrr

No there are not any (30 charrs)

It is not working either and no errors

You have try to use it in studio right?

Yeah I tried this in studio (30)

Can you try to use it in your game
not studio

Still doesn’t work, sorry (30 chars)

ok let me try in my game then ill tell you about result

Did your game pass id correctly?

Yeah I already made a gamepass

Try to use this

local MPS = game:GetService("MarketplaceService")
--local BindableEvent = game.ServerStorage.Event -- You can remove -- if you want :P
local GamepassID = --Change to your pass id

script.Parent.Touched:Connect(function(hit)
	print(hit.Parent.Name)
	if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if MPS:UserOwnsGamePassAsync(plr.UserId,GamepassID) then
print("ihavepass") -- remove this if you want
-- do stuff 
		end
		end
end)
1 Like