Hello, I am having an issue where every time you buy this developer product, it doubles the amount you get. Does anyone know how to fix this?

PRODUCT:

local id = 113109679

script.Parent.MouseButton1Click:connect(function()
	game.MarketplaceService:PromptProductPurchase(script.Parent.Parent.Parent.Parent.Parent, id)
end)



local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local productId = 113109679
 
-- define function that will be called when purchase finished
MarketplaceService.ProcessReceipt = function(receiptInfo) 
 
	-- find the player based on the PlayerId in receiptInfo
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
				-- handle purchase
			player.leaderstats.Steps.Value = player.leaderstats.Steps.Value + 100000
		end
	end
end	

POINT SYSTEM:

--SAVE SYSTEM--

local DSService = game:GetService('DataStoreService'):GetDataStore('test3')
game.Players.PlayerAdded:connect(function(plr)
	-- Define variables
	local uniquekey = 'id-'..plr.userId
	local leaderstats = Instance.new('IntValue', plr)
	local savevalue =  Instance.new('IntValue')
	leaderstats.Name = 'leaderstats'
	savevalue.Parent = leaderstats
	savevalue.Name = 'Steps'
	
	-- GetAsync
	local GetSaved = DSService:GetAsync(uniquekey)
	if GetSaved then
		savevalue.Value = GetSaved[1]
	else
		local NumbersForSaving = {savevalue.Value}
		DSService:SetAsync(uniquekey, NumbersForSaving)
	end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.leaderstats.Steps.Value}
DSService:SetAsync(uniquekey, Savetable)	
	
	
end)

--POINT ADDER--

local amount = 1;
local points = "Steps";
local wte = wait;
local vec3 = Vector3;

local function CheckForWalk(plr, hum)
    pcall(function()
        while wte() do
            if hum.MoveDirection ~= vec3.new(0, 0, 0) then --if the character is moving
                while wte(5/plr.leaderstats["Steps"].Value^(1/2)) do --while the player is moving, increase their step points each second.
                    if hum.MoveDirection ~= vec3.new(0, 0, 0) then
                        plr.leaderstats[points].Value = plr.leaderstats[points].Value + amount;
                    else
                        break;
                    end
                end
            end
        end
    end);
end

game.Players.PlayerAdded:connect(function(plr)--NOTE: this still breaks when "W" is held in and you die.
    plr.CharacterAdded:Connect(function(char)
        local hum = char:WaitForChild("Humanoid");
        CheckForWalk(plr, hum);
    end)
end)

4 comments

0

You could make a local number variable at the top of the product script, like local multiplier = 1, and then do player.leaderstats.Steps.Value = player.leaderstats.Steps.Value + (100000multiplier), then the line under do multiplier = multiplier2

0

no, it isn't supposed to double, but it does

0

just divide the amount of times that they already purchased

0

I guess that could work. Thanks