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

Is it possible to activate a click detector without actually clicking it ?

Asked by 7 years ago

For example, a button, is it possible to activate the click detector on a button without actually clicking it in lua ?

2
Why would you? hiimgoodpack 2009 — 7y
0
@hiimgoodpack Possibly a gamepass where you don't have to keep clicking DaWarTekWizard 169 — 6y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Yes you can. Here is an example that may help.

function OnClick() --The function for what the button does.
    print("BoxedHouses Rules!") --You dont have to keep this, it's an example.
    --What you want the button to do here.
end

game.Workspace.button.ClickDetector.MouseClick:connect(OnClick()) --Calls the function when the button is pressed.

--Here is your code.
game.Workspace.car.BrickColor = BrickColor.new("Really red")--You dont have to keep this, it's an example.
OnClick()--Calls the function without needing to press the button.

If it helps, please accept the answer, and if it doesn't, tell me any errors.

Ad

Answer this question