hey, i want to send "W" to a function through the use of heartbeat() and it says this:

17:23:19.661 - Attempt to connect failed: Passed value is not a function

and this:

17:23:20.411 - attempt to call a nil value (x46)

this is my code:

local function rotatePart(direction)
	if direction then
		print("W")
	end
end

if shifting == true then
	heartBeat1 = runService.Heartbeat:Connect(rotatePart("W"))
end

i have a bunch of conditions surrounding this code but the problem only appears when trying to pass the argument "W" to the above function.

3 comments

0

The :Connect() method takes a callback argument; is a function that is called by the signal, and fed arguments if information is supplied from the event. You’re trying to call a function in the callback argument, which is what’s causing your error. Pass the function name without parentheses.

0

You cannot provide an argument either, as the calling of the given function isn’t handled by you, you can optionally create a separate function which will call upon rotatePart with the arguments you desire.

0

thank you : D