This is the script that is supposed to add the money to your value which is in the localplayer, Why is it not adding to the players money value?
(The value is connected to a TextLabel in the StarterGui )
wait()
game.Players.PlayerAdded:Connect(function(plr)
local Money = plr.MoneyValue
local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local pid1 = 363906114
local pid2 = 363906921
local pid3 = 365773688
local pid4 = 365773990
local pid5 = 365774250
local pid6 = 365774578
local sid = 364007259 -- StarterPack
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == pid1 then
Money.Value = Money.Value + 1000
elseif receiptInfo.ProductId == pid2 then
Money.Value = Money.Value + 5000
elseif receiptInfo.ProductId == sid then
Money.Value = Money.Value + 10750
elseif receiptInfo.ProductId == pid3 then
Money.Value = Money.Value + 10000
elseif receiptInfo.ProductId == pid4 then
Money.Value = Money.Value + 25000
elseif receiptInfo.ProductId == pid5 then
Money.Value = Money.Value + 50000
elseif receiptInfo.ProductId == pid6 then
Money.Value = Money.Value + 100000
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end)

2 comments
PlayerAdded doesn't work for the client running that LocalScript. And ProcessReceipt is server side only.
How do I fix this then? Can you maybe write out what I need to change because I'm new to not very experienced