i want to make it so once any player buys a devproduct, it’ll increase ProductData numbervalue inside the counter.
The ShowNumber textlabel should show current value of my ProductData number. So i just need a script to store ProductData value, and increase it by +1 everytime a player buys devproduct, then everytime a new server creates it should load in the stored number and keep increasing it after someone buys product.
I got something working, but in the wrong way I’ll explain the parts:
ScreenGui Localscript
local MarketplaceService = game:GetService("MarketplaceService")
local ProductId = 1234567890 -- Change this ID with your Developer Product ID
script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, ProductId)
end)
Counter Script
local DeveloperProductID = 1234567890 -- Change this ID with your Developer Product ID
local Data = game.Workspace.Counter.ProductData -- Depending if you change the name of the part, you need to change the "ProductDoor" to your part name.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Purchased = false
game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == DeveloperProductID and not Purchased then
Data.Value = Data.Value + 1
end
end
end)
end)
So the first LocalScript works perfectly, nothing to add.
Now the second Normal Script:
It is inside the Counter (Part)
and checks if player got a DevProduct after buying one and adds one to your ProductData.
Here comes the problem:
If someone is buying it more than one time in one sitting, the number adds by another one so
the player has bought 2 DevProducts and the if sentences checks how many times it should go through. The ProductData.Value goes up to 3.
I have literally no idea maybe someone else might help with the MarketplaceService.
thanks, after a while i found the answer by myself - finally studied datastores and everything went well. but thanks for the reply, i’ll mark it as a solution!