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

How to add a transaction on textbutton?

Asked by 3 years ago
Edited 3 years ago

I'm making a donate button which allows people to donate to me. I have everything setup but now I just need the script that actually allows people to make the transaction. This is how the setup goes game > starter GUI > screen GUI > Frame >text button > script.

Edit: Figured it out, here is the script:

MPS = game:GetService("MarketplaceService")
id = 1138682487
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    MPS:PromptProductPurchase(player, id)
end)

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

it better be a local script for it to work properly. You detect button press

script.Parent.MouseButton1Down

then you use a remote event, fire it

game.ReplicatedStorage.RemoteEvent:FireServer()

then set up a listener with a server script

game.ReplicatedStorage.RemoteEvent.OnServerEvent

then make the transaction work, and you can pass information over from client to server using parameters like what ur buying

game.ReplicatedStorage.RemoteEvent:FireServer("chocolate")

but remember, automatically the first parameter for the listener is the player who fired the event, so set up parameters like this

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, parameter1)

if paremeter1 == "chocolate"...

I hope this is the answer you were looking for... if not, then i will help

0
If you are going to provide an answer, please make sure the code is actually spelled correctly. game.replicatedstorage doesn't exist, game.ReplicatedStorage does. WizyTheNinja 834 — 3y
0
sorry, i will fix that, but in my defense its pretty obvious of what it means AlexanderYar 788 — 3y
0
Where do I put the developer product ID? The server needs to know what to give the people. DudeHyper321 17 — 3y
0
in your question, you said you set everything else up... what did you set up? "I have everything setup" AlexanderYar 788 — 3y
0
I meant the GUI's DudeHyper321 17 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

***local id = 1138682487

script.Parent.MouseButton1Click:Connect(function() game:GetService("MarketplaceService"):PromtProductPurchase(game.Players.LocalPlayer, id) end)


The script I currently have

0
yes try it, if it fails then just look up how to do it there are working tutorials AlexanderYar 788 — 3y
0
Thing is it worked first time, but that was only a textbutton. I then put the textbutton in a frame, and it no longer works. DudeHyper321 17 — 3y
0
wait are you using a local script? Transactions cant be made with local sripts AlexanderYar 788 — 3y
0
and you cant detect button press using server script i think. so you have to use remote event. AlexanderYar 788 — 3y
View all comments (2 more)
0
I was using local script, it doesn't matter anymore because I figured it out - thanks so much for you help DudeHyper321 17 — 3y
0
no problem, and if oyu dont want to accept my answer, please upvote my comment, its okay if you dont though. AlexanderYar 788 — 3y

Answer this question