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

Why do i keep getting an error with this script?

i am trying to run a function that uses a clickdetector to start it but i keep getting the error that it was unable to connect the button and the function so whats wrong with the connect line?

button1e.ClickDetector.MouseClick:connect(buttonPressed(button1e, floor1, 1, floor1Arrived))

1 answer

You problem with the given code is that you have too many parameters on MouseClick. The only parameter of MouseClick is a pointer to the player who clicked. Also, the parameters of the function do not belong in the connection line, but rather in the function line.

local button1e = game.Workspace.Button1e -- location of button1e

function buttonPressed(playerWhoClicked) -- playerWhoClicked is the only possible parameter for the MouseClick function, varaible can be named anything though.
-- code
end

button1e.ClickDetector.MouseClick:connect(buttonPressed)

I'm not sure how your parameters for buttonPressed in your connection line fit into the script, so I can't really help you there unless you post more of your script.

1 comment

0

thank you for the help i did not know that was the only parameter mouseclick could have

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