I’m trying to make a script for fishing where you press a button to cast the rod, then have to wait for a timer and once that timer is done, it stops and a button to catch/reel in shows up.
The code works but once the timer finishes, “hi” is printed loads of times per second and im not sure why, can anyone help with making it completely stop the startTimer function?
local cast = script.Parent
local timer = script.Parent.Parent.FishingTimer
local catch = script.Parent.Parent.CatchButton
cast.MouseButton1Click:Connect(function()
cast.Visible = false
cast.Interactable = false
timer.Visible = true
local run = game:GetService("RunService")
local function formatTime(currentTime)
local hours = math.floor(currentTime / 3600)
local minutes = math.floor((currentTime - (hours * 3600))/60)
local seconds = math.floor((currentTime - (hours * 3600) - (minutes * 60)))
local format = "%02d:%02d:%02d"
return format:format(hours, minutes, seconds)
end
local function startTimer(currentTime)
run.Stepped:Connect(function(elapsed, step)
if currentTime > 0 then
currentTime -= step
timer.Text = formatTime(currentTime)
else
print("hi")
timer.Visible = false
catch.Visible = true
catch.Interactable = true
return
end
end)
end
startTimer(5)
end)