Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Connect error despite functions being defined?

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.

2 answers

✓ Accepted answer

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.

1 comment

0

Thank you (and WingedHorizen) for the answers! It (seems to, i can't tell completely since roblox is down) works fine now.

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)

3 comments

0

We posted answers almost at the same time :D Look at my answer for explaination.

0

You should look at Programical's response below. It's a little more detailed than my response.

0

Jep without the parentheses

This discussion is preserved as it was. New answers, comments, and votes are closed.