MouseButton1Click Not Firing

Hi!

So basically I’m trying to use the PromptPremiumPurchase() to offer a player Premium when they click on a Part. However, it doesn’t seem to work. I’ve added a print statement after the MouseButton1Click, but it isn’t printing, which shows me that the mouse click event is not firing. The Part has a Decal and a ClickDetector, and the following code is located in a LocalScript:

local MarketplaceService = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function(plr)
	MarketplaceService:PromptPremiumPurchase(plr)
end)

Any thoughts? Thanks for reading!

If its in a click detector then you need to reference the click detector!

Ex: script.Parent.ClickDetector.MouseClick:Connect(function(plr)
– Your Code
end)

MouseButton1Click is for UI’s and stuff like that

It is in a local script.


You should be using the .MouseClick signal of the ClickDetector inside of a Script.

Did you try using this in a normal script?

Along with the techniques mentioned above:

Adding a clickDetector and referencing that

1 Like

I tried @sportzebra’s method and input the code into a Server Script like @jimbot220 mentioned, and it worked! Thanks!

local MarketplaceService = game:GetService("MarketplaceService")

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	print("Clicked")
	MarketplaceService:PromptPremiumPurchase(plr)
end)
1 Like