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: Hi.

Previous Thread :: Next Thread 
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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 is not online. Nyxis
Joined: 15 Nov 2012
Total Posts: 3374
12 May 2014 03:16 PM
Mouse.Target
Report Abuse
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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 is not online. 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
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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 is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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 is not online. 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
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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 is not online. 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
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
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
masterCameron101 is not online. masterCameron101
Joined: 28 Mar 2010
Total Posts: 1377
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
TheProgrammingMaster is not online. TheProgrammingMaster
Joined: 20 Aug 2011
Total Posts: 7602
12 May 2014 06:40 PM
If the mouse is pointed at the sky it will error.
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
12 May 2014 06:45 PM
BlobbyBlob!!!!!!
Report Abuse
TheProgrammingMaster is not online. TheProgrammingMaster
Joined: 20 Aug 2011
Total Posts: 7602
12 May 2014 06:46 PM
OH GOD IT'S ONE OF THE LUA MASTERS! ALL BOW TO HIS GLORY!
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