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:




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