I’m trying to make a developer product that triggers a “coin shower” function in my game. It works fine the first time the player purchases it, but then after that it gets pretty buggy.
If the same player buys it > once, it does the event twice for some reason
No errors, it just repeats the code twice. I’ll show pics.
local player = game.Players.LocalPlayer local MARKET_PLACE_SERVICE = game:GetService("MarketplaceService") local PRODUCT_ID = 1540362914 script.Parent.MouseButton1Click:Connect(function() MARKET_PLACE_SERVICE:PromptProductPurchase(player, PRODUCT_ID) end) -- This works fine, but then in the server script...
You can ignore the last part of the next block I will show.
MARKET_PLACE_SERVICE.ProcessReceipt = function(info) local id = info.ProductId local Player = game.Players:GetPlayerByUserId(info.PlayerId) if id == productid then game.ReplicatedStorage["Robux Events"].CoinShower.CoinSgowerReturn:FireAllClients(Player.Name) --RIGHT HERE - If the player buys it more than once it runs twice - the remote event -- is fired twice, causing two notifications to be sent to the player, and causing double coin shower wait(10) local spawning = 0 while true do if spawning >= 50 then break end wait(.7) coin() spawning += 1 end end script.Enabled = false local scriptclone = script:Clone() scriptclone.Enabled = true scriptclone.Parent = game.ServerScriptService["Robux Purchases"].Storage script:Destroy() end
Any help is appreciated!!!