I was thinking of making a currency rain prompt when you click a surface GUI while using the TextButton.MouseButton1down:Connect( function(Variable)) but realize that “Variable” is always going to be nil.
I was hoping to prompt the user with a developer product purchase after clicking the button while also displaying “(user name) has just bought a currency rain” type deal.
Whats the most feasible way of doing this?
(I’m using a server script to do this, wasn’t sure if it needed to be a local script)
MouseButton1Down returns two values: an x and y-coordinate corresponding to the mouse’s position on-screen.
This should be done in a local script and it should be parented to StarterCharacter/Player Scripts:
local player = game.Players.LocalPlayer
local mps = game:GetService("MarketplaceService")
script.Parent.MouseButton1Down:Connect(function()
mps:PromptProductPurchase(player, PRODUCT_ID)
end)
If not already done, the Adornee property needs to be set to register event firing for MouseButton1Down and other events
Oh ok that makes more sense, from there I can probably just use an event to fire to the server to cause the actual rain itself and fire to all other clients the name of the person that bought it right?
You have to handle the purchase in a server script with ProcessReceipt because the player may deny the purchase. Yes, you have to fire to all clients, the name of the person who purchased it
Awesome, alright thanks guys, I’ll probably have some questions about the “ProcessReceipt” since this is the first time working with developer products but I’ll ask that when I get confused
Where are these receipts usually stored? on the tutorial it just datastores it, but if the player says tat they didn’t buy it, I can’t physically enter their datastore can i?
The example code in the page just saves it in a datastore, in case the receipt is processed more than once when you only bought it once - this doesn’t have any use to the developer, and you wouldn’t be able to get it anyways, other than what was mentioned above. Receipts are not stored anywhere.
You can’t store purchases in datastores because of its limit to the amount of data it can store, you can on an external web server with a database
I’ve been wanting to use the example provided for selling devproducts, because i don’t want to mess up by making a script myself when messing with robux, so is it not enough? should i somehow figure out anohter script? because it works so far at least in studio. Do i have to store receipts?
The main difference between DevProduct and Gamepass is that Roblox does not store information about them. And if you want to extend the use of this purchase for more than the current session, then you will have to store them somewhere between the player’s inputs.
[Russian]Главное отличие DevProduct от Gamepass как раз и состоит в том, что Roblox не хранит о них информации. И если вы хотите продлить использование данной покупки более чем на текущую сессию, то вам придётся их где-то хранить между входами игрока.
well my dev products are lost upon death, so I am fine with using the example script provided by the wiki? I don’t want to mess with it honestly, i don’t want to make a bad script that would cheat people out of their robux
This is how I handle products, don;t know if this will help you but it works for my uses:
-- local script
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Char)
Char:WaitForChild("Humanoid").Died:Connect(function()
mps:PromptProductPurchase(plr, PRODUCT_ID)
end)
end)
end)
-- In server script
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == YOURPRODUCTIDHERE then -- replace with your ID here
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
--What you want to happen here
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
thank you, it does because that’s exactly what i do, i was just worried i was suppose to store the receipt or something like that, anyway glad i don’t have to redo the scripts