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)
Found out what the problem was
I'm not sure about the problem, but I used your code and did what NiniBlackJackQc said to do and it worked perfectly fine.
This is what I would put in your LocalScript
local MS = game:GetService("MarketplaceService") MS:PromptProductPurchase(player,PUT_DEVELOPER_PRODUCT_ID_HERE)
This will prompt the player with the option of purchasing the custom developer product.
This is what I would put in your ServerScript
game.StarterGui.ResetPlayerGuiOnSpawn = false old_fog = game.Lighting.FogStart local MarketplaceService = game:GetService("MarketplaceService") MarketplaceService.ProcessReceipt = function(receiptInfo) local productId = receiptInfo.ProductId local playerId = receiptInfo.PlayerId local player = game:GetService("Players"):GetPlayerByUserId(playerId) --// Everything is the same besides this. local productName ------------------------------------------------------------------- if productId == 958879047 then local Coins = player.leaderstats:FindFirstChild("Coins") if Coins then Coins.Value = Coins.Value + 1000 end ------------------------------------------------------------------- end return Enum.ProductPurchaseDecision.PurchaseGranted end
This worked for me, if this helped you, let me know by selecting this as the answer!
~killerbrenden