MouseClick event doesn't fire

Hello. I was testing abillity of making working buttons locally. I need a button (lever) that would be working only on one client. I’ve tried to use mouseclick event detection in LocalScript.


According to this official API we can say - my localscript should probably work and make stuff i need - but it doesn’t. I’ve tried experiment: Script with simple hello world code and localscript with EXACT code from Roblox API (shown above). - However, result is nothing, no response, event doesn’t fire.

Why is this happening? Is it possible to get respond on event in LocalScript? Thanks

UPD: Link to make you sure that using LocalScript is mentioned in official API - ClickDetector

1 Like

Problem #1: Are you referencing the correct part on line 1? If there’s multiple parts in the workspace that share the same name then it might be referring to the incorrect part.

Problem #2: Localscripts only run in certain areas of the game, Those areas are listed here: LocalScript (roblox.com)

So, You have a couple of options.

  1. Have a normal script that when you click on it, it fires are remote to the player who clicked on it, doing what you want it to do, I wouldn’t recommend this in the longterm, but it is the easy way to do this.

  2. Have a general localscript ran somewhere where it can run, That handles client-sided aspects of the game. Levers could be put in a folder that the script loops through and handles. IMO this is the best way to handle it.

Anyway, Good luck with your game.

1 Like

Thanks, i really smh messed up and placed it in incorrect place. Thanks a lot for a link!