Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to add a transaction on textbutton?

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

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

5 comments

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.

0

sorry, i will fix that, but in my defense its pretty obvious of what it means

0

Where do I put the developer product ID? The server needs to know what to give the people.

0

in your question, you said you set everything else up... what did you set up? "I have everything setup"

0

I meant the GUI's

***local id = 1138682487

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


The script I currently have

6 comments

0

yes try it, if it fails then just look up how to do it there are working tutorials

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.

0

wait are you using a local script? Transactions cant be made with local sripts

0

and you cant detect button press using server script i think. so you have to use remote event.

0

I was using local script, it doesn't matter anymore because I figured it out - thanks so much for you help

0

no problem, and if oyu dont want to accept my answer, please upvote my comment, its okay if you dont though.

This discussion is preserved as it was. New answers, comments, and votes are closed.