I need help with a multiplier

something broke on line 17 idk what

local Multiplier = 1
local Time = math.random(10,20)
local Gold = game.Players.LocalPlayer.leaderstats.Gold
local timer = math.random(10,25)

while true do
	wait(Time)
	Multiplier = math.random(2,10)
	print(Multiplier.."x Multiplier Event!")
	wait(timer)
	print(timer.."Second"..Multiplier.."x Multiplier Event Ended")
	Multiplier = 1
	
end

script.Parent.MainGui.TextButton.MouseButton1Click:Connect(function()
	Gold.Value = Gold.Value * Multiplier --here
end)

Because of the while loop, the event never gets connected to. Place the while loop after the connection.

local Multiplier = 1
local Time = math.random(10,20)
local Gold = game.Players.LocalPlayer.leaderstats.Gold
local timer = math.random(10,25)

script.Parent.MainGui.TextButton.MouseButton1Click:Connect(function()
	Gold.Value *= Multiplier --here
end)

while true do
	task.wait(Time)
	Multiplier = math.random(2,10)
	print(Multiplier.."x Multiplier Event!")
	task.wait(timer)
	print(timer.."Second"..Multiplier.."x Multiplier Event Ended")
	Multiplier = 1
end

how would i do that exactly???

like this?

local Multiplier = 1
local Time = math.random(10,20)
local Gold = game.Players.LocalPlayer.leaderstats.Gold
local timer = math.random(10,25)

script.Parent.MainGui.TextButton.MouseButton1Click:Connect(function()
	Gold.Value = Gold.Value * Multiplier
end)

while true do
	wait(Time)
	Multiplier = math.random(2,10)
	print(Multiplier.."x Multiplier Event!")
	wait(timer)
	print(timer.."Second"..Multiplier.."x Multiplier Event Ended")
	Multiplier = 1
end

try that

local Multiplier = 1
local Time = math.random(10,20)
local Gold = game.Players.LocalPlayer.leaderstats.Gold
local timer = math.random(10,25)

coroutine.resume(coroutine.create(function()
while true do
	wait(Time)
	Multiplier = math.random(2,10)
	print(Multiplier.."x Multiplier Event!")
	wait(timer)
	print(timer.."Second"..Multiplier.."x Multiplier Event Ended")
	Multiplier = 1
	
end
end))

script.Parent.MainGui.TextButton.MouseButton1Click:Connect(function()
	Gold.Value = Gold.Value * Multiplier --here
end)

Reason why your code never worked is because it was just doing the loop and the textbutton event was never reached because of the loop. You can solve this by using coroutine or spawn()

this is an option, but why use a coroutine if you don’t need one, just put the loop under the event