generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

How do I activate a function with mouse click?

Previous Thread :: Next Thread 
THERYMAN543 is not online. THERYMAN543
Joined: 16 Apr 2016
Total Posts: 21
25 Apr 2016 02:00 AM
How do I activate a function with a mouse click.
Report Abuse
GetTheJobDone is not online. GetTheJobDone
Joined: 20 Apr 2016
Total Posts: 3008
25 Apr 2016 02:02 AM
Well it depends on if we're talking about GUIs or ClickDetectors.

ClickDetector:

clickDetector.MouseClick:connect(function(player)
-- Activated!
end)

GUIs:

guiElement.MouseButton1Click:connect(function()
-- Activated!
end)
Report Abuse
THERYMAN543 is not online. THERYMAN543
Joined: 16 Apr 2016
Total Posts: 21
25 Apr 2016 02:07 AM
thx
Report Abuse
Robertoman is not online. Robertoman
Joined: 10 May 2007
Total Posts: 6369
25 Apr 2016 03:31 AM
He may also be speaking about simply clicking, without any instances required within the game for the event to take place. You could put this script inside of a local script in the instance called starterplayerscripts.

local Mouse = game.Players.LocalPlayer:GetMouse()

Mouse.Button1Down:connect(function()
print('pressed left mouse button')
end)

Mouse.Button1Up:connect(function()
print('released left mouse button')
end)

Mouse.Button2Down:connect(function()
print('pressed right mouse button')
end)

Mouse.Button2Up:connect(function()
print('released right mouse button')
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image