Remote Event Messed Up

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
image
So in each button theres a Local script which can fire the event
image
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

And what doesn’t work exactly???

I don’t get this either. What’s not working?

1 Like

can you show your screen during testing?

1 Like

So instead of it just giving me the 10 for donating 10 it gave me amount for every possivle parameter as u can see in the screenshot
@Vanniris

how would you want me to do this? Just record it to show u?

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

play the game, then give me a screenshot while you’re playing the game

thats what it looked like when i donated 10 in game

screenshot your entire roblox screen while playing

1 Like

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

ok so how could I fix that? maxchars

just edited my post. charcharchar

1 Like

it works man tysm I really appreciate this help

the error is simple what happens is that you use the same remote event use several remote events or you must refer to which remote event send example:

ReplicatedStorage.DonatedRobux.OnServerEvent:Connect(function( " donar esto 10 "player, amountDonated)
	player.leaderstats.Donated.Value += amountDonated
end)
1 Like

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

1 Like

plus you don’t have to create different RemoteEvents as people say. Using certain parameters should be enough.

cough cough the memory

1 Like

if that is correct but I gave him several options just in case:

1 Like