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 — 7y

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.

01function OnClick() --The function for what the button does.
02    print("BoxedHouses Rules!") --You dont have to keep this, it's an example.
03    --What you want the button to do here.
04end
05 
06game.Workspace.button.ClickDetector.MouseClick:connect(OnClick()) --Calls the function when the button is pressed.
07 
08--Here is your code.
09game.Workspace.car.BrickColor = BrickColor.new("Really red")--You dont have to keep this, it's an example.
10OnClick()--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