Remote Event Messed Up

Please redo that code. It is unsafe and it cannot be trusted.

Try looping through all the buttons and making a table for each buttons ProductId.
And the ProcessReceipt in server script.

local donations = {
    ['Donate10'] = id,
    ['Donate100'] = id,
    ['Donate1000'] = id,
    ['Donate10000'] = id,
    ['Donate100000'] = id,
}

local screen_gui  = ... -- input the path for the screengui here
for i, v in pairs(screen_gui:WaitForChild('Frame'):GetChildren()) do
    if v:IsA('ImageButton') and string.sub(v.Name, 1, #('Donate')) == 'Donate' then
        local id = (donations[v.Name])
        if not (id) then continue end
        v.MouseButton1Click:Connect(function()
            game:GetService('MarketplaceSerice'):PromptProductPurchase(game.Players.LocalPlayer, id)
        end)
    end
end
        
1 Like

Man it’s not quite working and has no errors, heres what I have

local donations = {
	['Donate10'] = 1265665801,
	['Donate100'] = 1265665829,
	['Donate1000'] = 1265665853,
	['Donate10000'] = 1265665881,
	['Donate100000'] = 1265665924,
}

local screen_gui  = game.StarterGui.ScreenGui
for i, v in pairs(screen_gui:WaitForChild('Frame'):GetChildren()) do
	if v:IsA('TextButton') and string.sub(v.Name, 1, #('Donate')) == 'Donate' then
		local id = (donations[v.Name])
		if not (id) then continue end
		v.MouseButton1Click:Connect(function()
			game:GetService('MarketplaceSerice'):PromptProductPurchase(game.Players.LocalPlayer, id)
		end)
	end
end

and heres what it looks like
image

Make sure that the parameters you are passing into the remote event are the right ones.

That has nothing to do with this but your Script is not secured, everybody could send the RemoteEvent and get so much money they want, you should check on the Server if the Purchase was succesful.