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

Developer products help? [data store error]

Asked by
Prioxis 673 Moderation Voter
10 years ago

I have a script that if you buy the developer product (prompt by the button) then it'll TP your character to a certain position in the map

but when I click the button the purchase gui doesn't come up it gives me an error saying

datastore isn't accessible from the client???

Here's my script

script.Parent.MouseEnter:connect(function(Enter)
    script.Parent.Style = "RobloxButtonDefault"
    script.Parent.Size = UDim2.new(0, 215, 0, 55)
end)


script.Parent.MouseLeave:connect(function(Leave)
    script.Parent.Style = "RobloxButton"
    script.Parent.Size = UDim2.new(0, 200, 0, 50)
end)


local MarketplaceService = game:GetService("MarketplaceService")
local ID = 22158084
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") -- error is most likely in this line of code



MarketplaceService.ProcessReceipt = function(receiptInfo) 
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if  receiptInfo.ProductId == ID then
                player.Character.Torso.CFrame = CFrame.new(-8, 34.5, -52)
            end
        end 
    end
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    PurchaseHistory:IncrementAsync(playerProductKey, 1) 
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end


1 answer

Log in to vote
1
Answered by
AmiracIe 175
10 years ago

Data stores can only be accessed via server scripts. Make sure that's not in a local script.

0
OH okay thanks Prioxis 673 — 10y
Ad

Answer this question