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

Attempt to connect failed: Passed value is not a function?

local Shop = script.Parent
local exitButton = script.Parent.exitButton
function onClicked(Shop)
Shop:remove()
end
exitButton.MouseButton1Click:connect(onClicked(Shop)
	
)

https://gyazo.com/70ccf10cce547c46b113d025b6d0dd07

I get the error: Attempt to connect failed: Passed value is not a function? and I am not sure why. I have provided both the code, and the workspace. May someone help me? Many thanks.

2 comments

0

So connect was finally removed

2 answers

✓ Accepted answer

Use :Connect with capital C and :Destroy() :remove is deprecated

then do this its easier

exitButton.MouseButton1Click:connect(function()
Shop:Destroy()
end)

1 comment

0

Thanks so much!

###The MouseButton1Click passes no parameters, you also Connected the function wrong.

local onClicked
local Shop = script.Parent
local exitButton = Shop.exitButton

onClicked = function() -- No parameters
    Shop:Destroy() -- :Destroy(), not :remove()
end

exitButton.MouseButton1Click:Connect(onClicked) -- No extra brackets. 

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