|
| 12 May 2014 03:13 PM |
How would I get a part name when the player's mouse is over it?
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
| |
|
|
| 12 May 2014 03:17 PM |
Comes out nil, why? ._.
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
|
| 12 May 2014 03:17 PM |
print(Mouse.Target.Name)
I don't know why it could be coming out nil, unless Mouse.Target doesn't exist. |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 03:20 PM |
Tried printing mouse.Target.Name...
attempt to index field 'Target' (a nil value)
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
|
| 12 May 2014 03:21 PM |
well.. I'm stumped.
http://wiki.roblox.com/index.php?title=Target_(Property)/mouse |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 03:24 PM |
Use an if statement to make sure it's there if you're planning on indexing it.
print(mouse.Target) should work fine though... |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 03:25 PM |
Here's the script.
script.Parent.Equipped:connect(function(mouse) print(mouse.Target.Name) end)
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 03:38 PM |
Here's the tool if anyone wants to look at it.
http://www.roblox.com/tool-item?id=155469757
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 04:17 PM |
Bumpity bump 1.
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 12 May 2014 04:21 PM |
Player = game.Players.LocalPlayer Mouse = Player:GetMouse
Mouse.Move:connect(function() Target = Mouse.Target if Mouse.Target == nil then print("Not targetting anything.") else print("" .. Target .. " is targetted.") end end) |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 04:26 PM |
function arguments expected near 'Mouse' >.>
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 12 May 2014 04:27 PM |
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() -- oops
Mouse.Move:connect(function() Target = Mouse.Target if Mouse.Target == nil then print("Not targetting anything.") else print("" .. Target .. " is targetted.") end end)
Localscript startergui |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 04:31 PM |
vlekje513 provided you with a script which runs full time, but if you're looking for a tool, here's how you do it within those confines.
local Tool = script.Parent;
local Mouse; --Create a local variable so it can be referenced by all functions below. local function onMove() if Mouse.Target then print(Mouse.Target.Name); end end
local function onEquipped(m) Mouse = m; Mouse.Move:connect(onMove); end
Tool.Equipped:connect(onEquipped); |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 06:31 PM |
This worked for me. :D
script.Parent.Equipped:connect(function(m) m.Move:connect(function() if m.Target then print(m.Target.Name) end end) end)
~masterCameron101, advanced Lua programmer, certified graphics designer and geek. Have I help you? If so; support me by buying gear from any of my games, I'd appreciate it!~ |
|
|
| Report Abuse |
|
|
|
| 12 May 2014 06:40 PM |
| If the mouse is pointed at the sky it will error. |
|
|
| Report Abuse |
|
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
| |
|
|
| 12 May 2014 06:46 PM |
| OH GOD IT'S ONE OF THE LUA MASTERS! ALL BOW TO HIS GLORY! |
|
|
| Report Abuse |
|
|