#Developer product not working
26 messages · Page 1 of 1 (latest)
So I am making a developer product shop that when the player buys it, it gives them money (leaderstat)
But my leaderstats aren't set the normal way, they use Datastore2
Here is the current code:
local DataStore2 = require(game.ServerScriptService.Server.MainModule)
local DataStoreService = game:GetService("DataStoreService")
local currencyName = "money"
local PreviousPurhcases = DataStoreService:GetDataStore("PreviousPurchases")
local FIVE_THOUSAND = 1568934660
MarketplaceService.ProcessReceipt = function(receipt)
local ID = receipt.PlayerId.."-"..receipt.PurchaseId
local sucess = nil
pcall (function()
sucess = PreviousPurhcases:GetAsync(ID)
end)
if sucess then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
local player = game.Players:GetPlayerByUserId(receipt.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
else
if receipt.ProductId == FIVE_THOUSAND then
local player = game.Players:GetPlayerFromCharacter()
if player then
local coinsStore = DataStore2("money",player)
coinsStore:Increment(5000)
end
pcall(function()
PreviousPurhcases:SetAsync(ID,true)
end)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end```
And for example, for this other script it did work:
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local coinsStore = DataStore2("money",player)
coinsStore:Increment(15)
end
end)```
I wanna help but I am already boutta sleep a
I also use DataStore2 for my currency as well as developer products
Cool
So why isn't it working? Because I asked ChatGPT why it isn't working and it just says that it should be working and it doesn't detect any errors
But from what I see you can remove the pcalls since increment causes the datastore to save automatically
Yk what
I‘ll get on rq and see how mine is like
I remove pcalls and it still doesn't work
** You are now Level 2! **
I know, hold up
Alright thank you
that's the one I wrote and it works perfectly fine
You can use it too!
Do you understand what to replace?
You're welcome :D
