How would I get the Player who clicked the TextButton. The TextButton is in a surface GUI on a part in the workspace, so it is running off a Script, not a LocalScript.
local MarketplaceService = game:GetService("MarketplaceService") local productID = 515812556 script.Parent.MouseButton1Click:Connect(function(Player) print("working") if Player:GetRankInGroup(3563533) >= 30 then MarketplaceService:PromptProductPurchase(Player, productID) end end)
I believe that GUI's have a property called "Adornee". This means that you can put the GUI in the starter GUI and change the Adornee to the part that you're trying to display it on AND you can use local scripts. Correct me if I'm wrong and I'll take the answer down.
Unless you use a ClickDetector, there is no way the server is able to get who clicked the TextButton. Your best bet is to make it a Local Script that everyone has and pass the LocalPlayer in the parameters of the MarketPlaceService.
Last time I checked, MarketPlaceService still works on the client.
That way, it is able to trigger when the LocalPlayer presses the SurfaceGUI's TextButton and moreover prompt the LocalPlayer with a product.
So, change the button to a label, same settings, and put a click detector inside the part, and reference the click from the click detector. I don't think you could do it that way, it would also be a simpler way; maybe you could not 100% sure.
Part Hierarchy https://gyazo.com/7851f0a475707e70f30f16f01b4a6ca5
local clicker = script.Parent.Click local MarketplaceService = game:GetService("MarketplaceService") local productID = 515812556 clicker.MouseClick:Connect(function(player) if player:GetRankInGroup(3563533) <= 30 then MarketplaceService:PromptProductPurchase(player, productID) end end)
Just added onto vissequ's comment and made it all and showed you, thanks to vissequ's comment and me elaborating onto it, you're code is now fixed.