21:57:29.819 - Argument 3 missing or nil

hi, I was working at a Gun and i want the animation to be player every Frame while the gun is Eqquiped, but the first time it works and second time it errors this:
21:57:29.819 - Argument 3 missing or nil

the script:

RunService:BindToRenderStep(RenderName,Enum.RenderPriority.Camera.Value - 1,ChangeAnim(track))
		script.Parent.Unequipped:Connect(function()
			NotActivated = true
		    track:Stop()
			RunService:UnbindFromRenderStep(RenderName)
	end)

the function:


local function ChangeAnim(track)
	track:Play()
end

You called ChangeAnim and passed the return value (nil) to BindToRenderStep instead of passing the function ChangeAnim itself.

You wanted to write: RunService:BindToRenderStep(RenderName,Enum.RenderPriority.Camera.Value - 1,ChangeAnim)

2 Likes

But the function needs as a Argument a animation track, if i put ur code the function will break?

You can’t pass a variable through that way. It expects a function, if you type that it receives the returned value of a function instead. You can just use track in the function it binds to without making it a parameter so long as if track is a declared variable in an accessible scope

1 Like

If the track variable isn’t in scope where you declare ChangeAnim you can always introduce an anonymous function where it is in scope:

 RunService:BindToRenderStep(RenderName,Enum.RenderPriority.Camera.Value - 1, function() ChangeAnim(track) end)
4 Likes