I'm working on a shop GUI and I dont know how to call a function when a GUI has been pressed how would I do so? (IDK why the script is cut off)
function gravcoilpass() game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 10022825) end --somehow calls the function when GUI is clicked--
You might be looking for this: https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Click
script.Parent.MouseButton1Click:Connect(function(gravcoilpass)
You need to add a Button and in it a Local Script:
script.Parent.MouseButton1Click:Connect(function() game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 10022825) end)
For more information go on this website (like the other answer): https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Click