I have a coin that gives me a coin. Pretty simple.
I made a text button that shows the amount of coins you have times 40 (If you have 10 Coins, it will show 400 Coins).
If you click the button, it gives you a dev product you can buy for 24 Robux. If you buy it, I want your Coins to go up by the amount that was on on text label!
Alright, so that function is meant for the core process receipt handler. This should work for you in the normal script:
local MPS = game:GetService("MarketplaceService")
local function ChangeCurrencyAmount(CurrentTaps: number)
return math.ceil(CurrentTaps*40)
end
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1275015820 then
local Player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
Player.leaderstats.Coins.Value += ChangeCurrencyAmount(50)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
And just the LocalScript like this:
local Player = game:GetService("Players").LocalPlayer
local MPS = game:GetService("MarketplaceService")
Player.leaderstats.Coins.Changed:Connect(functon(NewValue)
script.Parent.Text = tostring(NewValue.." Taps")
end)
local Id = 1275015820
script.Parent.MouseButton1Click:Connect(function()
MPS:PromptProductPurchase(Player, Id)
end)
With all that being said, hopefully this is your solution! If this did work for you, I would appreciate it if you marked me as your solution! Have an amazing rest of your day/night!
Thanks so much for the script! The scripts didnโt directly work, so I had to do some tweaking. Thanks for the base code though!
My New Scripts:
Normal Script:
local MPS = game:GetService("MarketplaceService")
local function ChangeCurrencyAmount(CurrentTaps: number)
return math.ceil(CurrentTaps*40)
end
MPS.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == 1275015820 then
local Player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
Player.leaderstats.Coins.Value += ChangeCurrencyAmount(Player.leaderstats.Coins.Value)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
Local Script:
local Player = game:GetService("Players").LocalPlayer
local MPS = game:GetService("MarketplaceService")
local function ChangeCurrencyAmount(CurrentTaps: number)
return math.ceil(CurrentTaps*40)
end
local Amount = ChangeCurrencyAmount(Player:WaitForChild("leaderstats").Coins.Value)
Player.leaderstats.Coins.Changed:Connect(function(NewValue)
local Amount = ChangeCurrencyAmount(Player:WaitForChild("leaderstats").Coins.Value)
script.Parent.Text = tostring(Amount.." Taps")
end)
local Id = 1275015820
script.Parent.MouseButton1Click:Connect(function()
MPS:PromptProductPurchase(Player, Id)
end)