Hello everyone
So I was making a gamepass shop that give you money, like a in game currency gamepass shop. It works everything right but when I buy the gamepass, the in game currency doesnt appear. I give you here all the material in relation to this problem:
Currency script on the ServerScriptService
:
local replicatedStorage = game:GetService("ReplicatedStorage") local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("LeaderboardSave") local RemoteEvent = game.ReplicatedStorage.RemoteEvent game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local points = Instance.new("IntValue",leaderstats) points.Name = "Points" local HellCoins = Instance.new("IntValue", leaderstats) HellCoins.Name = "HellCoins" local HeavenCoins = Instance.new("IntValue", leaderstats) HeavenCoins.Name = "HeavenCoins" local AlienCoins = Instance.new("IntValue", leaderstats) AlienCoins.Name = "AlienCoins" local stats = ds:GetAsync(player.UserId) if stats ~= nil then points.Value = stats[1] HellCoins.Value = stats[2] HeavenCoins.Value = stats[3] AlienCoins.Value = stats[4] else points.Value = 0 HellCoins.Value = 0 HeavenCoins.Value = 0 AlienCoins.Value = 0 end end) game.Players.PlayerRemoving:Connect(function(player) local save = {} table.insert(save, player.leaderstats.HellCoins.Value) table.insert(save, player.leaderstats.HeavenCoins.Value) table.insert(save, player.leaderstats.AlienCoins.Value) table.insert(save, player.leaderstats.Points.Value) ds:SetAsync(player.UserId, save) end) RemoteEvent.OnServerEvent:Connect(function(player, Value, Item) -- player.leaderstats.Points.Value = player.leaderstats.Points.Value - Value game.ReplicatedStorage.Library[Item]:Clone().Parent = player:WaitForChild("Backpack") end)
Script that define the most important things of the system on the ServerScriptService
:
local MPS = game:GetService("MarketplaceService") MPS.ProcessReceipt = function(receiptInfo) if receiptInfo.ProductId == "1022102502" then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 500 return Enum.ProductPurchaseDecision.PurchaseGranted elseif receiptInfo.ProductId == "1022102764" then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 700 return Enum.ProductPurchaseDecision.PurchaseGranted elseif receiptInfo.ProductId == "1022102923" then local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId) player.leaderstats.HellCoins.Value = player.leaderstats.HellCoins.Value + 1000 return Enum.ProductPurchaseDecision.PurchaseGranted end end
Local Script on the BuyButton of the shop:
MPS = game:GetService("MarketplaceService") id = 1022102502 local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() MPS:PromptProductPurchase(player, id) end)
And I thing that is everything. I hope you can get the soltuion and thanks everyone for reading this post. It will really help me
Spideyalvaro999