Attempt to connect failed: Passed value is not a function
Always occurs on my script.
function OnUpdate() if updating==true then warn("Already updating.") elseif updating==false then print("Updating...") updating = true local name = vars.name.Value collectNew(name) if abort==true then warn("Update aborted.") abortFlush() abort=false elseif abort==false then wait(5) test() flush() end updating = false end end vars.name.Changed:Connect(OnUpdate())
vars is a variable leading to a folder, name is a string value. collectNew gathers information through a proxy on the Roblox API, with a little snippet making sure the passed value is not blank or nil.
function collectNew(name) if name then if vars.name.Value=="" then warn("Name is empty, aborting...") abort = true return true else print("Name check cleared.") end
flush() sends the retrieved information to string values in the var folder and then clears the information,
function flush() vars.outputI.Value = Group vars.outputII.Value = ID vars.outputIII.Value = Info wait() Group = "" ID = "" Info = "" end
whereas abortFlush() clears the information without sending it
function abortFlush() Group = "" ID = "" Info = "" end
the abort functions are in place because OnUpdate() fires as soon as the place starts, regardless of whether or not the name string is changed.
By passing onUpdate()
you are actually firing the function and passing what it returns. You should write onUpdate
to pass the function without firing it.
I may be mistaken here, and I am not a very experienced programmer, but isn't the line,
vars.name.Changed:Connect(OnUpdate())
supposed to be without the parentheses?
vars.name.Changed:Connect(OnUpdate)