This is the script in ServerScriptService
game.StarterGui.ResetPlayerGuiOnSpawn = false
old_fog = game.Lighting.FogStart
local MarketplaceService = game:GetService("MarketplaceService")
function getPlayerFromId(id)
for i,v in pairs(game.Players:GetChildren()) do
if v.userId == id then
return v
end
end
return nil
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = getPlayerFromId(playerId)
local productName
-------------------------------------------------------------------
if productId == 958879047 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 1000
end
-------------------------------------------------------------------
elseif productId == 958879379 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 5000
end
-------------------------------------------------------------------
elseif productId == 958879657 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 10000
end
-------------------------------------------------------------------
elseif productId == 958879909 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 25000
end
-------------------------------------------------------------------
elseif productId == 958880690 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 50000
end
elseif productId == 958881104 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 100000
end
elseif productId == 958881905 then
local Coins = player.leaderstats:FindFirstChild("Coins")
if Coins then
Coins.Value = Coins.Value + 500000
end
-------------------------------------------------------------------
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end`
This is the script in the ShopGui -> Buttons -> (All the buttons ID) with this in the gui folder
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
if v:isA("TextButton") then
v.MouseButton1Click:connect(function()
pcall(function()
if v:FindFirstChild("Pass") then
game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name))
else
game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
end
end)
end)
end
end
It actually worked yesterday but now it doesn't. I have no idea why. When you click +1000 coins ingame the gamepass / product pops up but when i buy it it doesn't give anything as it did yesterday. Anyone who knows how to fix this?
My Datastore in case it could be something that does so it doesn't work
local datastore = game:GetService("DataStoreService"):GetDataStore("GameStore35")
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Parent = leaderstats
local Eggs = Instance.new("IntValue")
Eggs.Name = "Eggs"
Eggs.Parent = leaderstats
local Rebirths = Instance.new("IntValue")
Rebirths.Name = "Rebirths"
Rebirths.Parent = leaderstats
Rebirths.Value = 1
local key = "user-" .. player.userId
local storeditems = datastore:GetAsync(key)
if storeditems then
Coins.Value = storeditems[1]
Eggs.Value = storeditems[2]
Rebirths.Value = storeditems[3]
else
local items = {Coins.Value, Eggs.Value, Rebirths.Value}
datastore:SetAsync(key, items)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local items = {player.leaderstats.Coins.Value, player.leaderstats.Eggs.Value, player.leaderstats.Rebirths.Value}
local key = "user-" .. player.userId
datastore:SetAsync(key, items)
end)

17 comments
Please reformat the messed up codeblocks... Are there any errors in the output associated with this?
No errors at all
I don't know if it is my Datastore that does so it the coins doesn't payout.
Is this developer products or a gamepass? https://developer.roblox.com/en-us/articles/Developer-Products-In-Game-Purchases | https://developer.roblox.com/en-us/articles/Game-Passes-One-Time-Purchases
You can find the player with this line; "game:GetService('Players'):GetPlayerByUserId(playerId)"
The difference is, developer products is in-game buyable and is an automatic transaction, multiple times. Gamepasses are a one-time buy, that gives the player the ability that you allow them to have once they join the game.
A developer product. Everything works fine killerbrenden, but when i buy the product nothing happens
https://gyazo.com/0d97077b3b44fb707ba0413602961220
Try what NiniBlackJackQc did, use GetPlayerByuUserId(playerId).
Where should i use that tho Killerbrenden?
local player = game:GetService('Players'):GetPlayerByUserId(playerId)
Change the line 17 to that
Still doesn't work
Put a prints everywhere
Where should i print() ?
I tried to print in the middle if Coins then ((((((( print(1) )))))) Coins.Value = Coins.Value + 1000 and it did work
I found out what the problem was myself :D it was a script in another folder that mate everything to not work