Donation logger logs me and my friends name

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I have a donation logger that every time someone donates via DevProduct from a proximity prompt it logs it into the discord server so that it can be counted up for 1st 2nd and 3rd place at the end of every month

  2. What is the issue? Include screenshots / videos if possible!


    It logs both of our names when only my friend is donating (they donated twice, but it shows me both times)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I could not find any solutions and my code looked fine so I didn’t know what to do.

local WebhookService = require(game:GetService("ServerScriptService"):WaitForChild("WebhookService")) --// Put the location of WebhookService here!
local WebhookURL = "https://webhook.lewisakura.moe/api/webhooks/notshowingthislalalalaalreadybeenwebhookbombedtwicetodaylalalalal" 



script.Parent.Triggered:Connect(function(plr)
	game:GetService("MarketplaceService"):PromptProductPurchase(plr,1715708780)
	game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(userId,productId,purchased)
		if purchased == true then
			local Webhook = WebhookService:CreateWebhook() --// Initializing the webhook object
			Webhook:SetMessage("----------------------") --// Setting the webhook's message
			
			local Embed = WebhookService:CreateEmbed() --// Create an embed object
			Embed:SetTitle("Tip received") --// Set the title of the embed
			Embed:SetDescription(plr.Name.." tipped") --// Give the embed a description
			Embed:AddField("ROBUX","5") --// Add a field!
			Embed:SetColor(Color3.fromRGB(0, 162, 255)) --// Give it some color!
			Embed:SetTimestamp() --// Make it show the current time!

			Webhook:AddEmbed(Embed) --// Add the embed to your webhook message!

			WebhookService:SendAsync(Webhook,WebhookURL) --// Send your webhook!
			
		end
		
	end)
end)

I am using WebhookService which is a third party model that I downloaded off the devforum, but I don’t think that is the problem because I tested static webhook posting without the proximity prompt and it only posted once. When I tested it solo it only posted my name (but my friend wasn’t there so I’m unsure what the issue is) There are no errors either

1 Like

You’re logging the person who owns the product, not the one who bought it.

Code:

local WebhookService = require(game:GetService("ServerScriptService"):WaitForChild("WebhookService")) --// Put the location of WebhookService here!
local WebhookURL = "https://webhook.lewisakura.moe/api/webhooks/notshowingthislalalalaalreadybeenwebhookbombedtwicetodaylalalalal" 

script.Parent.Triggered:Connect(function(plr)
	game:GetService("MarketplaceService"):PromptProductPurchase(plr,1715708780)
end)

game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(userId,productId,purchased)
	if not purchased then
		return
	end
	
	local player = game:GetService("Players"):GetPlayerByUserId(userId)
	
	if player then
		local Webhook = WebhookService:CreateWebhook() --// Initializing the webhook object
		Webhook:SetMessage("----------------------") --// Setting the webhook's message

		local Embed = WebhookService:CreateEmbed() --// Create an embed object
		Embed:SetTitle("Tip received") --// Set the title of the embed
		Embed:SetDescription(player.Name.. " tipped") --// Give the embed a description
		Embed:AddField("ROBUX","5") --// Add a field!
		Embed:SetColor(Color3.fromRGB(0, 162, 255)) --// Give it some color!
		Embed:SetTimestamp() --// Make it show the current time!

		Webhook:AddEmbed(Embed) --// Add the embed to your webhook message!

		WebhookService:SendAsync(Webhook, WebhookURL) --// Send your webhook!
	end
end)

You should also move the connection outside the .Triggered event, to avoid memory leaks.

2 Likes

I am unsure if this works, so I will wait until I have another person to get on, so far it works on solo so my hopes are high.

2 Likes

Did it work?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.