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 » Scripters
Home Search
 

Re: Mouse.Target.Parent?

Previous Thread :: Next Thread 
fullajeh is not online. fullajeh
Joined: 30 Jan 2013
Total Posts: 196
11 Jul 2016 10:29 AM

I've been trying to use Mouse.Target, but I couldn't get the parent of It. I tried In 2 ways.


First Way
------------------------------

tool=script.Parent

tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
if mouse.Target~=nil then
local sel=Instance.new("SelectionBox", mouse.Target)
sel.Adornee=sel.Parent
local plr=sel.Parent.Parent
print(plr.Name)
else
return
end
end)
end)

----------------------------


Second way

----------------------------

local plr=game.Players.LocalPlayer
plr.CharacterAdded:wait()
local char=plr.Character
tool=script.Parent

tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
if mouse.Target.Parent:FindFirstChild("Humanoid") then
print(mouse.Target.Parent.Name)
end
end)
end)

-----------------------------


Report Abuse
runnergavin is not online. runnergavin
Joined: 04 Mar 2013
Total Posts: 468
11 Jul 2016 10:32 AM
How much R$? [32]
Report Abuse
fullajeh is not online. fullajeh
Joined: 30 Jan 2013
Total Posts: 196
11 Jul 2016 10:32 AM
Bump


Report Abuse
runnergavin is not online. runnergavin
Joined: 04 Mar 2013
Total Posts: 468
11 Jul 2016 10:33 AM
How much R$? [64]
Report Abuse
doggy00 is not online. doggy00
Joined: 11 Jan 2011
Total Posts: 3571
11 Jul 2016 10:34 AM
Did you get any output errors?


--game.Players.doggy00.Life:remove() error- Life is not a valid member of Player
Report Abuse
fullajeh is not online. fullajeh
Joined: 30 Jan 2013
Total Posts: 196
11 Jul 2016 10:35 AM
Nope. None at all, It just kept printing 'Workspace'.


Report Abuse
runnergavin is not online. runnergavin
Joined: 04 Mar 2013
Total Posts: 468
11 Jul 2016 10:35 AM
8=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================D
Report Abuse
fullajeh is not online. fullajeh
Joined: 30 Jan 2013
Total Posts: 196
11 Jul 2016 10:36 AM
Bump again.


Report Abuse
doggy00 is not online. doggy00
Joined: 11 Jan 2011
Total Posts: 3571
11 Jul 2016 10:40 AM
So it prints Workspace?

This is part of your script.

local plr = sel.Parent.Parent
print(plr.Name)


This must mean that sel.Parent.Parent is Workspace. I assume this isn't intentional since the variable's name is "plr".


--game.Players.doggy00.Life:remove() error- Life is not a valid member of Player
Report Abuse
Ortron is online. Ortron
Joined: 19 Jul 2013
Total Posts: 1297
11 Jul 2016 10:40 AM
The first script works but the tool only equips if the tool has a Handle

To fix this inside the tool properties untick the box which says requires handle


Report Abuse
fullajeh is not online. fullajeh
Joined: 30 Jan 2013
Total Posts: 196
11 Jul 2016 10:42 AM
I've already done that, what I want the first one to do Is print out the Player's name [I'm clicking on my own torso when I spawn In]. It doesn't create the selectionbox on the torso, or anything, It prints "Workspace", so I'd assume that It thinks workspace Is the parent. How do I change that?


Report Abuse
Ortron is online. Ortron
Joined: 19 Jul 2013
Total Posts: 1297
11 Jul 2016 10:43 AM
the mouse ignores the local player

i think anyway


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