I have a devproduct that is to give players +30 on their leaderstats, but for some odd reason it is giving them 100 or 120 or 150, the number is completely random, wth is going on?
I have this in a GUI button in a LocalScript so people can purchase the devproduct
wait(0.1)
local player = game.Players.LocalPlayer
local currency = player:WaitForChild('leaderstats').Coins
local itembutton = script.Parent--- MAIN BUTTON
local desc = script.Parent.Parent.Parent.Desc
local indextext = script.Parent.Text -- REMEMBERS TEXT IN MAIN BUTTON
local devid = idhere
itembutton.MouseEnter:connect(function()
desc.Text = '30 Coins'
end)
itembutton.MouseLeave:connect(function()
itembutton.Parent.Parent.ItemImage.Image = ''
desc.Text = ''
end)
itembutton.MouseButton1Click:connect(function()
game:GetService('MarketplaceService'):PromptProductPurchase(game.Players.LocalPlayer, devid)
end)
I then have this in a serverscript to check for people that have the devproduct
MarketplaceService = game:GetService("MarketplaceService")
local DataStore = game:GetService("DataStoreService"):GetDataStore("coincurrency")
local devid = IDplaceholderhere
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, v in pairs(game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == devid then
v.leaderstats.Coins.Value = v.leaderstats.Coins.Value + 30
else
wait()
print("Gave 30 coins to player")
--end)
end
end
end
end
What exactly am I doing wrong here?
