Having some problem with receipt info or remote event

I’m trying to make a sound play when someone is donating with a developer product and I got the UI to work but not the sound.
I got some help with the remote event part of the script but we have no idea why it isn’t working
I was told to put the local script in StarterGui but I don’t know why.

Script in ServerScriptService

local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ProductID = 1182433131--Donation Id1

local ProductID2 = 1182472598--Donation Id2

local ProductID3 = 1182472800--Donation Id3

local ProductID4 = 1182462265--Donation Id4

local ProductID5 = 1183533639

local ID6 = 1183534505 

local remoteEvent = ReplicatedStorage:WaitForChild("DonatedRobux")

MarketplaceService.ProcessReceipt = function(ReceiptInfo)
	if ReceiptInfo.ProductId == ProductID or ReceiptInfo.ProductId == ProductID2 or ReceiptInfo.ProductId == ProductID3 or ReceiptInfo.ProductId == ProductID4 or ReceiptInfo.ProductId == ProductID5 or ReceiptInfo.ProductId == ID6 then
		local Player = game.Players:GetPlayerByUserId(ReceiptInfo.PlayerId)
		local PlayerGui = Player.PlayerGui.DonateUI

		wait(1.3)
		PlayerGui.SuccessMessage.Visible = true
		remoteEvent:FireClient(ReceiptInfo.PlayerId)
		print("Thank you for your donation!")
		wait(15)
		PlayerGui.SuccessMessage.Visible = false

		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Local Script in StarterGui

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("DonatedRobux")

remoteEvent.OnClientEvent:Connect(function()
	script.CashSoundEffect:Play()
end)

I asked another developer and she said this.
Bilde_2021-06-26_223632

Is the gui popping up on your screen?

This is because (I think) the server can’t access the player gui so it can’t play the sound for them
Make sure the sound is inside that local script as it is stated here:

And finally make sure that there are no errors

The UI is being set to visible when donating so yes, it’s popping up
Bilde_2021-06-26_225937

This is probably part of the problem:

FireClient uses a Player instance, and doesn’t accept a UserId instead. That line should instead be:

remoteEvent:FireClient(Player)

If you’re getting errors, please add them to your post.

2 Likes

It worked, thanks.
But I just got a new error


I only get this error when I’m playing but not in studio, I don’t know what I’m doing wrong
Bilde_2021-06-26_234413

Otherwise, you can manage UI operations on the client, rather than the server.

yea thats what i was talking about before the server can’t see the clients playergui so all u gotta do is make it visible from the local script
Like this

remoteEvent.OnClientEvent:Connect(function()
	script.CashSoundEffect:Play()
	script.Parent.SuccessMessage.Visible = true
	wait(15)
	script.Parent.SuccessMessage.Visible = false
end)

Good idea, will do it.
Thanks!