Tip Jar Help Gamepass

local TipGamepassId = 9010948
local player = game.Players.LocalPlayer
local MarketplaceService = game:GetService("MarketplaceService")
local click = workspace.Head.ClickTip

	
click.MouseClick:Connect(function()
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, TipGamepassId)	
end)
	
	if hasPass == true then
		print("Player has pass")
		else
			MarketplaceService:PromptGamePassPurchase(player, TipGamepassId)
		end
	end)

image

For some reason when I click the “head” in this case the gamepass prompt doesn’t pop up? Tried everything and idk why?

Is that local script in workspace?

"A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service"
1 Like

So how would I fix it in a regular script? Cause someone told me I couldnt access local players in a script, so I have no idea what to put in the Script.

You could do it like this:

local TipGamepassId = 9010948
local MarketplaceService = game:GetService("MarketplaceService")
local click = workspace.Head.ClickTip

	
click.MouseClick:Connect(function(player) -- look at this thing
	local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, TipGamepassId)	
end)
	
if hasPass == true then
	print("Player has pass")
	else
		MarketplaceService:PromptGamePassPurchase(player, TipGamepassId)
	end
end)
2 Likes

I will test it out! Thank you for your help.

1 Like

I know nothing about scripting but if you want it to be re-purchasable, you will have to make a developer product, search on YouTube how to make one if you don’t know already.
And then while trying to change it to the developer product, there comes a ID and this is a simple change from the game-pass ID to the developer product’s ID, is easy.
I hope this helps.

1 Like

Are you aware on how I would turn that code in dev product code? Cause when I just replace IDs it doesn’t work.

1 Like

There are videos on YouTube about developer products that could help quite a bit.