Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
ZenTGE 4
5 years ago
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.

0
So connect was finally removed OBenjOne 190 — 5y
0

2 answers

Log in to vote
0
Answered by 5 years ago

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

then do this its easier

exitButton.MouseButton1Click:connect(function()
Shop:Destroy()
end)
0
Thanks so much! ZenTGE 4 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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. 

Answer this question