So pretty much every time someone donates it fires a remoteEvent where the parameter is the amount donated and when I tested this in game it gave me amount for every button possible for donating
So in each button theres a Local script which can fire the event
Heres the local script which is the exact same apart from the Parameter for the event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketPlaceService = game:GetService("MarketplaceService")
local id = 1265665801
script.Parent.MouseButton1Click:Connect(function()
MarketPlaceService:PromptProductPurchase(game:GetService("Players").LocalPlayer, id)
end)
local success, errormessage = pcall(function()
MarketPlaceService.PromptProductPurchaseFinished:Connect(function(player, assetId: id, isPurchased)
if isPurchased == true then
ReplicatedStorage.DonatedRobux:FireServer(10)
end
end)
end)
Now heres the server script which receives the event
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
ReplicatedStorage.DonatedRobux.OnServerEvent:Connect(function(player, amountDonated)
player.leaderstats.Donated.Value += amountDonated
end)
All help would be highly appreciated, thank you in advance
if anyone doesn’t understand:
for an example there’s 3 buttons named x,y,z
x is for donating 10
y is for donating 100
z is for donating 1000
when the op clicked button x, button x y and z fires the remote event and adds the leadboard up too
theres nothing else to see tho all the buttons are seperated and thats just what happens to leaderboard when i donate 10 unless u want me to screenshare on discord youve seen all there is
nvm i understand there’s multiple dev products with different prices, right? so
MarketPlaceService.PromptProductPurchaseFinished
fires everytime you buy a dev product. since each localscript have this event, every localscript fires the remoteevent with different values
in order to solve this you need to put an if statement below the event like
if assetId == 69420 then
ReplicatedStorage.DonatedRobux:FireServer(10)
end
Also, you can just use one script. Let’s try this:
Delete all scripts from the buttons.
Create a script under ScreenGui, and do the following:
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote_Donated = ReplicatedStorage:WaitForChild("DonatedRobux")
local donateButtons -- forget this, refer to my last comment
function onDonate10Activated()
local id = 1 -- id for 10
MarketplaceService:PromptProductPurchase(Players. LocalPlayer, id)
local success, errormessage = pcall(function()
MarketplaceService.PromptProductPurchaseFinished:Connect(function(player, assetId: id, purchaseSuccess)
if purchaseSuccess then
ReplicatedStorage.DonatedRobux:FireServer(10)
end
end)
end)
-- repeat for each button
-- im on mobile, wont bother to continue writing.
This is not so recommended if the player has bad internet then it could bug or it would take longer to trigger the event what you should do is use different remote events
edit : or refer to a remote event in a different way