Remote event script not working properly

the script is supposed to make a gui tween when a developer product is purchased. there’s 3 dev products so i made three different guis for it, the thing is sometimes it works and most times it doesn’t (i didnt change the script)

i know that the script i wrote is probably ineffective or broken so if i can get some help on it itll be great.

prompt:

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

local productID = 000000 -- theres three seperate scripts for the products  

script.Parent.MouseButton1Click:Connect(function(promptPurchase)
	local player = Players.LocalPlayer
	MarketplaceService:PromptProductPurchase(player, productID)
end)

server script or handler:

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

local donationEvent = ReplicatedStorage:WaitForChild("DonationDevProduct")


function processReceipt(receiptInfo)
	local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if receiptInfo.ProductId == 1132359762 or 1132359887 or 1132359951 then -- the three dev products
		donationEvent:FireClient(player, receiptInfo.ProductId) -- remoteevent
	end
	
	print(player.Name .. " purchased " .. receiptInfo.ProductId)	
	
	return Enum.ProductPurchaseDecision.PurchaseGranted
end


MarketplaceService.ProcessReceipt = processReceipt

local script for the gui:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local donationEvent = ReplicatedStorage:WaitForChild("DonationDevProduct")

local guione = script.Parent.ten
local guitwo = script.Parent.fifty
local guithree = script.Parent.hundred

local function onDonated(ProductId)
	if ProductId == 1132359762 then
		print("10")
		guione:TweenPosition(UDim2.new(0.915, 0, 0.112, 0), nil, nil, 0.2)
		wait(3)
		guione:TweenPosition(UDim2.new(1.15, 0, 0.112, 0), nil, nil, 0.2)
		
	elseif ProductId == 1132359887 then
		print("50")
		guitwo:TweenPosition(UDim2.new(0.915, 0, 0.112, 0), nil, nil, 0.2)
		wait(3)
		guitwo:TweenPosition(UDim2.new(1.15, 0, 0.112, 0), nil, nil, 0.2)
		
	elseif ProductId == 1132359951 then
		print("100")
		guithree:TweenPosition(UDim2.new(0.915, 0, 0.112, 0), nil, nil, 0.2)
		wait(3)
		guithree:TweenPosition(UDim2.new(1.15, 0, 0.112, 0), nil, nil, 0.2)
	end
end

donationEvent.OnClientEvent:Connect(onDonated)

the print() worked when i removed the tween script from the code. but with the code it didnt print the number either. i tried doing

script.Parent:WaitForChild("guiname")

but it didn’t fix the problem.

Try changing
receiptInfo.ProductId == 1132359762 or 1132359887 or 1132359951 then
To
receiptInfo.ProductId == 1132359762 or receiptInfo.ProductId == 1132359887 or receiptInfo.ProductId == 1132359951 then
as that would be the correct syntax for what you’re trying to accomplish

(I’m on mobile right now so please excuse any poor writing)

2 Likes

thank you for the correction, it worked very well! :happy3: