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.
Use :Connect with capital C and :Destroy() :remove is deprecated
then do this its easier
exitButton.MouseButton1Click:connect(function() Shop:Destroy() end)
MouseButton1Click
passes no parameters, you also Connect
ed 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.