How can I make a Timed Double Coins Dev Product. I tried making it like this
local part = script.Parent
local MarketplaceService = game:GetService("MarketplaceService")
local coins = 10
local exp = 15
local function processReceipt(receiptInfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print(player.Name .. " just bought " ..receiptInfo.ProductId)
if receiptInfo.ProductId == 1163195720 then
coins *= 2
wait(1800)
coins = coins
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
part.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not plr or deb then return end
local lstats = plr.leaderstats
deb = true
lstats.Coins.Value += coins
lstats.Exp.Value += exp
wait(1)
deb = false
end)
The script is meant to double how many coins they get for half an hour and then whenever they touch the part that gives them the coins it doubles it. When the player touches it the first time it does work, but then it starts going to much higher numbers and I don’t know what is wrong.