-
What do you want to achieve?
There are 5 developer products, 4 provide coins and 1 provides a sword tool.When you purchase a developer product, the players coin leaderstat is increased accordingly (or) the player is given a sword -
What is the issue?
Once the player purchases any product, all products activate at once. The player is given a sword and the sum of all coins -
What solutions have you tried so far?
I redefined marketplace service after each function but i didn’t notice a difference.
events are fired via a textbutton gui
local mkp = game:GetService("MarketplaceService")
mkp.PromptProductPurchaseFinished:Connect(function(userId,product,purchased)
local player = game.Players:GetPlayerByUserId(userId)
local timealive = player.leaderstats:FindFirstChild("Coins")
if purchased then
timealive.Value = timealive.Value +250
end
end)
game.ReplicatedStorage:WaitForChild("Buy1Coin").OnServerEvent:Connect(function(player)
mkp:PromptProductPurchase(player,1195449239)
end)
-- first above
local mkp = game:GetService("MarketplaceService")
mkp.PromptProductPurchaseFinished:Connect(function(userId,product,purchased)
local player = game.Players:GetPlayerByUserId(userId)
if purchased then
game.ReplicatedStorage.Sword:Clone().Parent=player.Backpack
end
end)
game.ReplicatedStorage:WaitForChild("Swordbuy").OnServerEvent:Connect(function(player)
mkp:PromptProductPurchase(player,1195450585)
end)
-- sword purchase above
local mkp = game:GetService("MarketplaceService")
mkp.PromptProductPurchaseFinished:Connect(function(userId,product,purchased)
local player = game.Players:GetPlayerByUserId(userId)
local timealive = player.leaderstats:FindFirstChild("Coins")
if purchased then
timealive.Value = timealive.Value +600
end
end)
game.ReplicatedStorage:WaitForChild("Buy2Coin").OnServerEvent:Connect(function(player)
mkp:PromptProductPurchase(player,1195449240)
end)
-- second purchase
local mkp = game:GetService("MarketplaceService")
mkp.PromptProductPurchaseFinished:Connect(function(userId,product,purchased)
local player = game.Players:GetPlayerByUserId(userId)
local timealive = player.leaderstats:FindFirstChild("Coins")
if purchased then
timealive.Value = timealive.Value +1250
end
end)
game.ReplicatedStorage:WaitForChild("Buy3Coin").OnServerEvent:Connect(function(player)
mkp:PromptProductPurchase(player,1195449242)
end)
-- third purchase above
-- fourth
local mkp = game:GetService("MarketplaceService")
mkp.PromptProductPurchaseFinished:Connect(function(userId,product,purchased)
local player = game.Players:GetPlayerByUserId(userId)
local timealive = player.leaderstats:FindFirstChild("Coins")
if purchased then
timealive.Value = timealive.Value +3250
end
end)
game.ReplicatedStorage:WaitForChild("Buy4Coin").OnServerEvent:Connect(function(player)
mkp:PromptProductPurchase(player,1195449241)
end)
-- fourth