Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Data Store not being created?

Asked by
drahsid5 250 Moderation Voter
10 years ago

Well, I'm making a system in which when you purchase a Developer product, the text of a text box (and some more info) is saved in a data store, a different player can view the data. But the data store doesn't seem to be created (printing the children of it, only the data of data stores doesn't seem to exsist.) So, can anyone help me out here? My code:


local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local TAL = 0
local D = 0
local Less = 0
local Gfx = 0
local Tst = 20242729
local Buy = script.Parent.Parent.Buy
function Click()
if Buy.Value == 0 then
print "An error occured defining what you're buying..."
_G.Error()
elseif Buy.Value == 1 then
game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent.Parent, TAL)
elseif Buy.Value == 2 then
game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent.Parent, D)
elseif Buy.Value == 3 then
game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent.Parent, Less)
elseif Buy.Value == 4 then
game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent.Parent, Gfx)
elseif Buy.Value == 5 then
game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent.Parent, Tst)
end
end

local MS = game:GetService("MarketplaceService")
local DS = game:GetService("DataStoreService"):GetDataStore("ProcessReceipt")
MS.ProcessReceipt = function(receiptInfo) 
local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
    if PurchaseHistory:GetAsync(playerProductKey) then
    return Enum.ProductPurchaseDecision.PurchaseGranted
end 
for i, player in ipairs(game.Players:GetPlayers()) do
        if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == TAL then
local DataToSend = game:GetService("DataStoreService"):GetDataStore(player.Name.." "..Buy.Value.." "..receiptInfo.PurchaseId) --Every purchase gets their own data store.
local Text = script.Parent.Parent.Info.Text
DataToSend:UpdateAsync(player.Name..Buy.Value..receiptInfo.ProductId, function(TextToSend)
local TextToSend = player.Name.." purchased a Thumbnial/ad/logo:"..Text
return TextToSend
end)
elseif receiptInfo.ProductId == D then
local DataToSend = game:GetService("DataStoreService"):GetDataStore(player.Name.." "..Buy.Value.." "..receiptInfo.PurchaseId) --Every purchase gets their own data store.
localText = script.Parent.Parent.Info.Text
DataToSend:UpdateAsync(player.Name..Buy.Value..receiptInfo.ProductId, function(TextToSend)
local TextToSend = player.Name.." purchased a 3D Scene:"..Text
return TextToSend
end)
elseif receiptInfo.ProductId == Less then
local DataToSend = game:GetService("DataStoreService"):GetDataStore(player.Name.." "..Buy.Value.." "..receiptInfo.PurchaseId) --Every purchase gets their own data store.
localText = script.Parent.Parent.Info.Text
DataToSend:UpdateAsync(player.Name..Buy.Value..receiptInfo.ProductId, function(TextToSend)
local TextToSend = player.Name.." purchased Lessons."
return TextToSend
end)
elseif receiptInfo.ProductId == D then
local DataToSend = game:GetService("DataStoreService"):GetDataStore(player.Name.." "..Buy.Value.." "..receiptInfo.PurchaseId) --Every purchase gets their own data store.
localText = script.Parent.Parent.Info.Text
DataToSend:UpdateAsync(player.Name..Buy.Value..receiptInfo.ProductId, function(TextToSend)
local TextToSend = player.Name.." purchased a Gfx Pack:"..Text
return TextToSend
end)
elseif receiptInfo.ProductId == Tst then
local DataToSend = game:GetService("DataStoreService"):GetDataStore(player.Name.." "..Buy.Value.." "..receiptInfo.PurchaseId) --Every purchase gets their own data store.
localText = script.Parent.Parent.Info.Text
DataToSend:UpdateAsync(player.Name..Buy.Value..receiptInfo.ProductId, function(TextToSend)
local TextToSend = player.Name.." purchased [Test]:"..Text
return TextToSend
end)
end 
end
end

PurchaseHistory:SetAsync(playerProductKey, true)
 return Enum.ProductPurchaseDecision.PurchaseGranted        
end

script.Parent.MouseButton1Click:connect(Click)

Answer this question