Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got function)

Hello devs! So I am making tool but it errors at this line of code :

local idle = animator:LoadAnimation(script.Parent:WaitForChild("Idle"))

local use = animator:LoadAnimation(script.Parent:WaitForChild("Toggle"))

script.Parent.Equipped.Connect(function()

idle:Play()

end)

This is the error :
Players.JaceMorphing.Backpack.CampingLantern.LocalScript:17: invalid argument #1 to 'Connect' (RBXScriptSignal expected, got function)

2 Likes

You need to put a colon between equipped and connect instead of a dot.

local idle = animator:LoadAnimation(script.Parent:WaitForChild("Idle"))

local use = animator:LoadAnimation(script.Parent:WaitForChild("Toggle"))

script.Parent.Equipped:Connect(function()

idle:Play()

end)
3 Likes

Ohh my bad! A typo! I was doing it fast because I had online classes and I didn’t notice!

1 Like
local idle = animator:LoadAnimation(script.Parent:WaitForChild("Idle"))
local use = animator:LoadAnimation(script.Parent:WaitForChild("Toggle"))

script.Parent.Equipped:Connect(function()
	idle:Play()
end)

Reformatted with the aforementioned fix.

I already figured out my typo, I was late for online class then because I lost track of time