No output, no errors?

Nothing simply happens in the script and all I want is a visual way to represent the timers. It mostly should have 0 issues and it doesnt seem to show anything, no number change or anything.

image

TimerTextLabel Code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local timer = require(ReplicatedStorage.TimerModule):Create('LongJumpTimer')

ReplicatedStorage.Timer.Event:Connect(function(startValue)
	local params = {
		Start = startValue,
		IntervalDuration = 1,
		Separator ="",
		Separators = ":",
		Countdown = true,
		Target = 0,			
	}

	timer:SetTickSound(4843088994)		

	for i,v in pairs(game:GetDescendants()) do
		if v.Name == "LongJumpTL" then
			if v:GetAttribute('Timer') == true then
				timer:SetUI(v)
				break
			end
		end
	end
end)

Visual Timer Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local leftFrame = script.Parent:WaitForChild("LeftBG"):WaitForChild("LeftFrame")
local rightFrame = script.Parent:WaitForChild("RightBG"):WaitForChild("RightFrame")

ReplicatedStorage.Timer.Event:Connect(function(startValue)
	local ts = game:GetService("TweenService")
	local ti = TweenInfo.new(startValue, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)

	local numValue = Instance.new("NumberValue")


	numValue.Changed:Connect(function()


		local rightRot = math.clamp(numValue.Value - 180, -180, 0)

		rightFrame.Rotation = rightRot


		if numValue.Value <= 180 then

			leftFrame.Visible = false


		else

			local leftRot = math.clamp(numValue.Value - 360, -180, 0)

			leftFrame.Rotation = leftRot

			leftFrame.Visible = true
		end
	end)


	local function progressBar()

		numValue.Value = 0

		local progressTween = ts:Create(numValue, ti, {Value = 360})
		progressTween:Play()
	end


	progressBar()
end)

Module Script:

local funcs = {}
local RunService = game:GetService('RunService')
funcs.__index = funcs
local timers = {}
local watches = {}

local defaultParams = {
	Start = 60,
	IntervalDuration = 1,
	Separator = ':',
	Separators = 1,
	Countdown = false,
	Target = 0
}

function funcs:Create(Name)
	local finishedEvent = Instance.new('BindableEvent')
	local pausedEvent = Instance.new('BindableEvent')
	if Name then

		timers[Name] = {
			Parameters = {	Start = 0,
				IntervalDuration = 0,
				Separator = ':',
				Separators = 0,
				Countdown = false,
				Target = 0},
			Status = 'Idle',
			UI = nil,
			Current = 0,
			Sound = '',
			Start = os.time(),
			Paused = pausedEvent.Event,
			Finished = finishedEvent.Event,
			StartTimer = Instance.new('BindableEvent')
		}

		local new = {}

		--Timer Parameters
		new['Parameters'] = {
			Start = 60,
			IntervalDuration = 1,
			Separator = ':',
			Separators = 0,
			Countdown = true,
			Target = 0}
		new['Status'] = 'Idle'
		new['UI'] = nil
		new['Current'] = 0
		new['IntervalDuration'] = 0
		new['Sound'] = ''
		new['StartTime'] = math.floor(os.time())
		new['Paused'] = pausedEvent.Event
		new['Finished'] = finishedEvent.Event

		-- Timer functions

		function new:Start(Timer)
			local timer = new
			if timer then
				if not timer.UI then
					warn('Timer "'.. Timer .. '" has no UI')
				end
				local params = timer.Parameters
				timer.Status = 'Running'
				timer.Current = timer.Parameters.Start
				coroutine.wrap(function()
					repeat
						if params.Separators == 0 then
							if timer.Parameters.Countdown == true then
								timer.Current = timer.Current - 1
							else
								timer.Current = timer.Current + 1
							end

							if timer.UI then
								timer.UI.Text = timer.Current
							end

							wait(timer.Parameters.IntervalDuration)
						end

						if params.Separators == 1 then
							if params.Countdown == true then
								timer.Current = timer.Current - 1
								local show = ''
								local secs = timer.Current % 60
								local mins = math.floor(timer.Current/60)

								if string.len(secs) == 1 then
									secs = '0'.. secs
								end

								if string.len(mins) == 1 then
									mins = '0'.. mins
								end

								show = mins .. params.Separator .. secs
								timer.UI.Text = show
								wait(timer.Parameters.IntervalDuration)
							else
								timer.Current = timer.Current + 1
								local show = ''
								local secs = timer.Current % 60
								local mins = math.floor(timer.Current/60)

								if string.len(secs) == 1 then
									secs = '0'.. secs
								end

								if string.len(mins) == 1 then
									mins = '0'.. mins
								end

								show = mins .. params.Separator .. secs
								if new.Sound ~= '' then
									local sound = Instance.new('Sound')
									sound.Parent = game:GetService('SoundService')
									sound.Name = 'Tick'
									sound.SoundId = new.Sound
									sound:Play()
									sound.Ended:Connect(function()
										sound:Destroy()
									end)
								end
								timer.UI.Text = show
								wait(timer.Parameters.IntervalDuration)
							end
						end

						if params.Separators == 2 then
							if params.Countdown == true then
								timer.Current = timer.Current - 1

								local show = ''
								local secs = timer.Current % 60
								local mins = math.floor(timer.Current / 60)
								local hrs = math.floor(timer.Current/3600)

								if mins > 59 then
									repeat mins = mins - 60

									until mins < 60

								end

								if string.len(secs) == 1 then
									secs = '0'.. secs
								end

								if string.len(mins) == 1 then
									mins = '0'.. mins

								end

								if string.len(hrs) == 1 then
									hrs = '0'.. hrs
								end

								show = hrs.. params.Separator .. mins.. params.Separator .. secs
								timer.UI.Text = show
								wait(timer.Parameters.IntervalDuration)
							end
						end
					until 
					timer.Current == timer.Parameters.Target or timer.Status == 'Paused'
					if timer.Current == timer.Parameters.Target then
						finishedEvent:Fire()
					else
						pausedEvent:Fire()
					end
				end)()
			else
				warn('Timer '.. Timer .. ' not found')
			end
		end

		timers[Name].StartTimer.Event:Connect(function()
			new:Start()
		end)

		function new:SetParams(TimerParams)

			if TimerParams then
				local valid = true
				local start = TimerParams.Start
				local interval = TimerParams.IntervalDuration
				local separator = TimerParams.Separator
				local separators = TimerParams.Separators
				local countdown = TimerParams.Countdown
				local target = TimerParams.Target

				if start then
					if type(start) ~= 'number' then
						warn('Start must be a number')
						valid = false
					end
				else
					TimerParams.Start = defaultParams.Start
					warn('Start not specified')
				end

				if interval then
					if type(interval) ~= 'number' then
						warn('IntervalDuration must be a number')
						valid = false
					end
				else
					TimerParams.IntervalDuration = defaultParams.IntervalDuration
					warn('IntervalDuration not specified')
				end

				if separator then
					if type(separator) ~= 'string' then
						warn('Separator must be a string')
						valid = false
					end
				else
					TimerParams.Target = defaultParams.Target
					warn('Separator not specified')
					TimerParams.Separator = defaultParams.Separator
				end

				if separators then
					if type(separators) ~= 'number' then
						warn('Separators must be a number')
						valid = false
					else
						if separators < 0 or separators > 2 then
							warn('There can only between 0 to 2 separators')
							valid = false
						end
					end
				else
					TimerParams.Separators = defaultParams.Separators
					warn('Separators not specified')
				end

				if countdown then
					if type(countdown) ~= 'boolean' then
						warn('Countdown must be a boolean')
						valid = false
					end
				else
					TimerParams.Countdown = defaultParams.Countdown
					warn('Countdown not specified')
				end

				if target then
					if type(target) ~= 'number' then
						warn('Target must be a number')
						valid = false
					end
				else
					TimerParams.Target = defaultParams.Target
					warn('Target not specified')
				end


				if valid == true then
					timers[Name].Parameters = TimerParams
					new.Parameters = TimerParams
				end

			else
				warn('TimerParams not specified')

			end
		end

		function new:Pause()
			if new.Status == 'Running' then
				new.Status = 'Paused'
			else
				warn('Timer "'.. Name .. '" is not running; did not pause')
			end
		end

		function new:Resume()
			if new.Status == 'Paused' then
				new.Status = 'Running'
				new:SetParams({
					Start = new.Current,
					IntervalDuration = new.Parameters.IntervalDuration,
					Separator = new.Parameters.Separator,
					Separators = new.Parameters.Separators,
					Countdown = new.Parameters.Countdown,
					Target = new.Parameters.Target})
				new:Start()
			else
				warn('Timer "'.. Name .. '" is not paused; did not resume')
			end
		end

		function new:SetUI(Element)
			local success,errorMessage = pcall(function()
				Element.Text = ''
			end)

			if success then
				new.UI = Element
			else
				warn('UI Element "'.. Element .. '" does not have a Text property')
			end
		end

		function new:SetSound(SoundID)
			local MarketplaceService = game:GetService'MarketplaceService'
			local Success, Response = pcall(MarketplaceService.GetProductInfo, MarketplaceService, SoundID)

			if Success then
				if Response.AssetTypeId == Enum.AssetType.Audio.Value then
					new.Sound = 'rbxassetid://' .. SoundID
				else
					warn(SoundID .. ' is not a sound ID')
				end
			else
				warn(SoundID .. ' not found')
			end
		end

		function new:GetStatus()
			return new.Status
		end

		return new

	else
		warn('No name specified for timer')
	end
end

function funcs:CreateStopWatch(Name)
	if Name then
		local watch = {}
		local stopEvent = Instance.new('BindableEvent')
		watch['Stopped'] = stopEvent.Event
		watch['Status'] = 'Idle'
		watch['Begin'] = 0

		function watch:Start(UI,Separator,StartTime)
			if not UI then
				warn('UI not specified')
			end
			local start = tick()
			watch.Begin = start
			local stop = false
			local sep = Separator

			if not Separator then
				sep = ':'
			end

			if StartTime then
				start = StartTime
			end

			coroutine.wrap(function()
				repeat
					local diff = tick() - start
					local min = math.floor(diff / 60)
					local hr = math.floor(diff / 3600)
					local sec = diff - min*60
					local mil = math.floor((sec - math.floor(sec)) * 100)
					sec = math.floor(sec)

					if string.len(min) == 1 then
						if min ~= 0 then
							min = '0'.. min
						end
					end

					if string.len(sec) == 1 then
						sec = '0'.. sec
					end

					if mil == 0 then
						mil = '00'
					end

					if min == 0 then
						UI.Text = sec .. sep .. mil
					else
						if hr == 0 then
							UI.Text = min.. sep.. sec.. sep.. mil
						else
							UI.Text = hr.. sep.. min.. sep.. sec..sep ..mil ..sep
						end
					end
					watches[Name] = watch
					RunService.Heartbeat:Wait()
				until watch.Status == 'Stopped'
			end)()


		end

		function watch:Stop()
			watch.Status = 'Stopped'
			stopEvent:Fire()
			return tick() - watch.Begin

		end
		watches[Name] = watch
		return watch
	else
		warn('No name provided for stop watch')
	end
end

function funcs:GetTimers()
	local TIMERS = {}

	for i,v in pairs(timers) do
		TIMERS[i] = {
			Start = v.Start,
			IntervalDuration = v.IntervalDuration,
			Separator = v.Separator,
			Separators = v.Separators,
			Countdown = v.Countdown,
			Target = v.Target}
	end

	return TIMERS
end

function funcs:Start(Name)
	if Name then
		if timers[Name] then
			timers[Name].StartTimer:Fire()
		end
	else
		warn('No name provided')
	end
end

return funcs

The script that is supposed to start it:

task.wait(5)
game.ReplicatedStorage.Timer:Fire(5)

Since we don’t have much of a starting point to look for the error, can you please place print() statements throughout the script, at several different points, so you can narrow down where it breaks

1 Like

sure! I’ll let you know when ive placed them.

1 Like

Alright, so I remade the script from scratch and still nothing. I decided to use a remote function but I don’t know if thats right.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

function NewTimer()
	local Timer = script.CircleTimer:Clone()
	Timer.Parent = script.Parent.TimerHolder
	
	return Timer
end

function StartTimer(startValue)
	
	local Timer = NewTimer()
	
	local TextLabel = Timer.Timer
	
	for i=0, startValue, 1 do
		task.wait(1)
		TextLabel.Text = i
	end
	
	local leftFrame = Timer:WaitForChild("LeftBG"):WaitForChild("LeftFrame")
	local rightFrame = Timer:WaitForChild("RightBG"):WaitForChild("RightFrame")
	
	local ts = game:GetService("TweenService")
	local ti = TweenInfo.new(startValue, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)

	local numValue = Instance.new("NumberValue")


	numValue.Changed:Connect(function()

		local rightRot = math.clamp(numValue.Value - 180, -180, 0)

		rightFrame.Rotation = rightRot


		if numValue.Value <= 180 then
			leftFrame.Visible = false
		else

			local leftRot = math.clamp(numValue.Value - 360, -180, 0)
			leftFrame.Rotation = leftRot
			leftFrame.Visible = true
		end
	end)

	local function progressBar()

		numValue.Value = 0

		local progressTween = ts:Create(numValue, ti, {Value = 360})
		progressTween:Play()
	end
	
	progressBar()
end

ReplicatedStorage.Timer.OnClientEvent:Connect(function(startValue)
	StartTimer(startValue)
end)

add some print statements as mentioned earlier

I managed to fix it! I just had to make it more neater. Thank you for helping me troubleshoot it as well!

@SeargentAUS
@Veesuuu

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.