local DebounceCreator = {}
local ParameterRequest = require(game.ServerStorage.Parameter)
DebounceCreator.Debounce = function(waitTime, f, argument)
local executing = false
return function()
if not executing then
executing = true
if next(argument) ~= nil then
argument = ParameterRequest:new(argument)
f(argument:unpack())
else
f()
end
wait(waitTime)
executing = false
end
end
end
No need to know what ParameterRequest does I think, I'm getting an error at
if next(argument) ~= nil then
argument = ParameterRequest:new(argument)
f(argument:unpack())
else
f()
end
however if I change it to:
if next(argument) ~= nil then
foo = ParameterRequest:new(argument)
f(parameter:unpack())
else
f()
end
For some reason changing the name of 'argument' to 'foo' makes the code work all of a sudden. Why is this so?

7 comments
What is the error you're receiving?
15:09:00.044 - Workspace.Part.OnTouch:13: bad argument #3 (Color3 expected, got nil) I only get this error when it's argument = ParameterRequest:new(argument) but for some reason changing it to foo = ParameterRequest:new(argument) removes that error and the code works perfectly, no logical error or anything.
If it works fine with "foo", then just use "foo".
well, there has to be a reason for why it works that way... Which is what I'm looking for, any other variable name works except itself
This is just a guess but maybe "argument" is a term for some other thing so it gets confused when you use that. Try using other things that aren't argument and see if they work.
Didn't work, changed the name of argument to some other name and it still didn't work. Maybe it has something to do with closures?
holy son of god i finally figured out the problem