Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how would i call a function when a gui is pressed?

Asked by 3 years ago
Edited 3 years ago

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--

3 answers

Log in to vote
1
Answered by
Raccoonyz 1092 Donator Moderation Voter
3 years ago

You might be looking for this: https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Click

0
thanks LTRNightmare 66 — 3y
Ad
Log in to vote
0
Answered by
Gingerely 245 Moderation Voter
3 years ago

script.Parent.MouseButton1Click:Connect(function(gravcoilpass)

Log in to vote
0
Answered by 3 years ago

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

Answer this question