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
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: made my first tool EVAH :D

Previous Thread :: Next Thread 
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:20 PM
i've been pushing it off for months, but today i finally decided to learn :P

function mouse(m)
print("clicked")
end
script.Parent.Selected:connect(function(m)
m.Button1Down:connect(function() mouse(m) end)
print("Selected")
end)

script.Parent.Deselected:connect(function()
print("Deselected")
end)

Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
21 Sep 2011 12:21 PM
Nope.
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
21 Sep 2011 12:23 PM
Actually, you can do it a bit differently. :o

script.Parent.Selected:connect(function(m)
print("Selected")
m.Button1Down:connect(function()
print("clicked")
end)
end)

The whole moving the mouse to another function is not entirely necessary. :3


Good job, none-the-less! Keep up with the knowledge!
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:27 PM
:o thats a little more simple, i think i'll use that way, and the way you find what object you click is: 'm.Target' right? If i wanted to find the name i could just do: 'm.Target.Name' ?
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
21 Sep 2011 12:28 PM
m.Target is the part you are hovering at, not clicking at.
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:30 PM
:o ok, so how would i find the object which is clicked?
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
21 Sep 2011 12:31 PM
Check mouse.Target when mouse.Button1Down is fired.
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:32 PM
duh, that makes sense :P
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
21 Sep 2011 12:38 PM
Mouse.Hit works, too.
It returns the position that you were pointing.
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
21 Sep 2011 12:39 PM
Mouse.Target = Object
Mouse.Hit = Position
Report Abuse
Miro034 is not online. Miro034
Joined: 07 Oct 2009
Total Posts: 6568
21 Sep 2011 12:41 PM
ohnow I get it...Thx grim...:D
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:42 PM
thanks for the help, now i'm going to try to make something a little more complicated :3
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
21 Sep 2011 12:44 PM
http://wiki.roblox.com/index.php/RBX.lua.Mouse_(Object)
For more functions,properties and events.
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:50 PM
heres a quick script i made for my game, but for some reason the .Selected event isn't firing :\

script.Parent.Selected:connect(function(m)
local player = game.Players.LocalPlayer
print("Selected")

m.Button1Down:connect(function()
local targ = m.Target
print("click")

if targ ~= nil then
print(targ.Name)

if targ.Name == "WaterSource" then
local mag = (targ.Position - game.Workspace.WaterSource.Position).magnitude

if mag <= 5 then
player.Hunger.Frame.Tbar1.Size = UDim2.new(0.4, 0, 0.3, 0)
player.Character.Humanoid.Health = 100
end
end
end
end)
end)

script.Parent.Deselected:connect(function()
print("Deselected")
end)

Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
21 Sep 2011 12:52 PM
Make sure it's a;
Localscript
and inside of a Hopperbin
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 12:52 PM
yup, its a local script and its in a hopperbin
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 01:00 PM
i did notice a minor error, but its still not the source of the problem

local mag = (player.Character.Torso.Position - targ.Position).magnitude
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
21 Sep 2011 01:02 PM
whaaaaaat? i changed that exact line ^ and it fixed it :O
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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