Upgrade System Bug

Hello there. Since the release of Ultimate Clickers, the game has experienced some bugs, most notable being obtaining upgrades all by sudden, without player knowing that.

Here’s the code:

-- mmm Module represents the primary module, it is used for
-- Currency suffixes and upgrade prices

-- The Tables
local upgstring = {
	AutoClick = {
		Name = "AutoClick",
		Num = 0,
	},
	ClickSpeed = {
		Name = "ClickSpeed",
		Num = 0,
	},
	GemsBonus = {
		Name = "GemsBonus",
		Num = 0,
	},
} -- only three of them will be shown for simplicity

-- Load the upgrade part, when the player joins

function LoadValues(Player)
local tcode = datastore2(upgradeds,Player)
	
   local success, err = pcall(function()
	     local value = (tcode:Get(upgstring))
	     for i,v in pairs(value) do
		    local newc = DataFolder.Upgrades:FindFirstChild(tostring(v.Name))
		    newc.Value = v.Num
	     end
		
	     for i,v in pairs(DataFolder.Upgrades:GetChildren()) do
		    if v and v:IsA("NumberValue") then
			  if v.Value > mmm:GetMaximum(v.Name) then
				 v.Value = mmm:GetMaximum(v.Name)
			  end
		   end
	    end
    end)
end

-- Save the upgrade part

function SaveValues(Player,types,ifsaveornot)
    local upgds = datastore2(upgradeds,Player)
    local utable = upgstring
	for i,v in pairs(DataFolder.Upgrades:GetChildren()) do
	   if v:IsA("NumberValue") then
		  utable[v.Name].Name = v.Name
		  utable[v.Name].Num = v.Value
	   end
	end
	upgds:Set(utable,upgstring)
	if ifsaveornot == true then
		upgds:Save(utable,upgstring)
	end
end

-- Upgrade function

game.ReplicatedStorage.RemoteEvents.Upgrade.OnServerInvoke = function(plr,category,loop,times)
	local data = game.ServerStorage.DataFolder:WaitForChild(plr.UserId)
	local bonus = tonumber(data.Bonus.BonusRebirths.Value)
	
	if category ~= "Rank" then
		local level = data.Upgrades:FindFirstChild(category)
		if level ~= nil then
			local price = mmm:GetPrice(category,level.Value)
			if level.Value < mmm:GetMaximum(category) then
				if spendgold(plr,price,secretcode) then
					local x = tonumber(level.Value)
					x = x + 1
					level.Value = tostring(x)
					game.ReplicatedStorage.RemoteEvents.FlushShop:InvokeClient(plr)
					return true
				else
					return false
				end
			else
				return 0
			end
		end
    end -- I only include the upgrade part of the function, loop is only used for ranks
end)

Here is the feedback of certain people, related to this horrible bug:image image
image
image
image

What should I correct in the code? Please leave a comment if you figured out a solution.
Thank you so much.

Have you tried replicating the bug? Have you asked the people who experienced the bug what they were doing?

1 Like

Well, I heard that some people got all of upgrades since they came in for the first time in the game, this is the first scenario of the bug.

I will credit the person who found the solution on description of the game when the update is released, increasing the opportunity further.

1 Like

I am looking through your code and have seen that this part, where the Name = "" in all values in the upgstring table, actually shouldn’t be, or is that intentional for this post?

Because as you seem to use ds2, so If the player playing for first time that table is going to used.

local newc = DataFolder.Upgrades:FindFirstChild(tostring(v.Name))

And break if it’s what I can see

1 Like

So basically FindFirstChild or the empty names led to full upgrades, right?