My string table keeps having this error: attempt to compare nil with number

I’m getting this error:

Apparently my table is always nil.

local SpookyFunctions = { 
"Spooky Child Scream", 
"Spooky Moan", 
"Spooky Scared Breathing", 
"Spooky Scared Breathing 2", 
"Spooky Scared Sob 1", 
"Spooky Scared Sob 2", 
"Spooky Zombie Call"

local SpookyFunc = table.ToString( SpookyFunctions, "Spooky Functions", true )
if timer.TimeLeft(SpookyFunc) < 60 and timer.TimeLeft("Spooky Muffled Cry") < 20 then RedoTheTimers1()

Would anyone happen to know where I went wrong?

If you could post the entire error that’d help a ton. My only guess from the code you’ve provided is

timer.TimeLeft is returning nil because the timer doesn’t exist.

That’s probably actually from checking timer.TimeLeft. Make sure you’re creating the timers before you check how much time is left on them, and that you’re creating both with the names you’re using here.
I’m not sure why, the timers are all there.

timer.TimeLeft and

table.ToString don’t work the way you think they do.

table.ToString returns a string that resembles the structure of the table you gave it.

timer.TimeLeft checks the amount of time left on the given timer identifier. You never create a timer with that identifier.

I was hoping to use a table of all the timers, so I don’t have to do or this or that or this instead I can just put the table name. So the table was supposed to give it all the timer identifiers.

There’s no way to accomplish this?

You can still use the table, just use a loop to check for each identifier.

I’m fairly new to lua, I’m not sure how I’d go about this.

You know how to do what you did above, but not be able to create a loop?

Is this still the script to periodically play sounds that you were working on? Can you explain what all you want it to do, cos it sounds like the way you’re doing it is a lot more complicated than it could be

My friend helped me do some of that, problem is, we’re both stuck on this now.

[editline]21st October 2017[/editline]

Yes, same script. I just wanted to prevent timers from going off if it’s only around 20 seconds after the last timer went off.

[editline]21st October 2017[/editline]

I just need an example of what bigdogmat is suggesting.

If you just want a solution for now:

local min = 60
for k, name in pairs(SpookyFunctions) do
local timeleft = timer.TimeLeft(name)
if timeleft ~= nil and timeleft < min then
min = timeleft
if min < 60 and timer.TimeLeft(“Spooky Muffled Cry”) < 20 then
– do whatever
[editline]20th October 2017[/editline]

So, after reading your pastebin link – you want all the other sounds to play independently, no matter how close to one other, and town_muffled_cry1.wav is the only one that delays itself after one of the others plays, right?

You don’t need to use a Tick hook for this – try using a local variable to store the last time one of the other timers went off, and then have SpookyMuffledCry delay itself:
local lastSound = 0

local function SpookyChildScream()
for k,v in pairs(player.GetAll()) do
lastSound = CurTime()

local function SpookyMuffledCry()
if lastSound + 20 > CurTime() then
timer.Adjust(“Spooky Muffled Cry”, …)
for k,v in pairs(player.GetAll()) do