I’m trying to make an upgrade that lowers the printingTime
The issue is the MouseClick event seems to not work
-- UPGRADES
-- Upgrade1
local function upgrade1()
if printed >= 35 then
printed -= 35
printingTime -= 0.5
simulator.Purchase.Playing = true
simulator.Upgrade1:Destroy()
else
simulator.NotEnough.Playing = true
end
end
simulator.Upgrade1.ClickPart.ClickDetector.MouseClick:Connect(upgrade1)
I’ve tried to rewrite the code, checked the ClickDetectors reference:
And i tried to change the function to an anonymous function but nothing worked
Full code:
local simulator = script.Parent
local clicker = simulator["Main Clicker"]
local printing = 0
local printingTime = 2
local printed = 0
local printingShown = clicker.PrintingShown.SurfaceGui.TextLabel
local printedShown= clicker.PrintedShown.SurfaceGui.TextLabel
local isTouched = false
local clickAmount = 1
local function addPrint()
if isTouched == false then
isTouched = true
local luckyNumber = math.random(1,100)
print(luckyNumber)
if luckyNumber == 50 then
clickAmount += 1
simulator.Lucky.Playing = true
end
printing += clickAmount
printingShown.Text = "Printing: "..tostring(printing)
simulator.ClickSound.Playing = true
wait(0.275)
isTouched = false
end
end
clicker.ClickPart.ClickDetector.MouseClick:Connect(addPrint)
while true do
while printing > 0 do
wait(printingTime)
printing -= 1
printed += 1
printingShown.Text = "Printing: "..tostring(printing)
printedShown.Text = "Printed: "..tostring(printed)
end
wait(0.05)
end
-- UPGRADES
-- Upgrade1
local function upgrade1()
if printed >= 35 then
printed -= 35
printingTime -= 0.5
simulator.Purchase.Playing = true
simulator.Upgrade1:Destroy()
else
simulator.NotEnough.Playing = true
end
end
simulator.Upgrade1.ClickPart.ClickDetector.MouseClick:Connect(upgrade1)