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: Clicking a player, mouse.target, and detecting the player

Previous Thread :: Next Thread 
gogo6104 is not online. gogo6104
Joined: 10 Feb 2010
Total Posts: 326
07 Jul 2017 12:10 PM
I already have the script along the lines of:

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

mouse.Button1Down:connect(function()
if mouse.Target and mouse.Target.Parent:FindFirstChild("Humanoid") then
local playerFound = mouse.Target.Parent.Name
print(playerFound)
end
end)

^ That script should print the name of the player you clicked; if I click another player, that should find whatever I clicked of them (torso, left arm, etc), find it's parent, and grab it's name (Which obviously should be the model which is the player's name), then print it.

This works, kinda. It's only detecting it if I click certain parts of the player. I have to keep rapidly clicking all over the player's body before finally finding a spot where the mouse.Target detects the humanoid; what am I doing wrong? Is there like a natural way that your mouse.Target goes through a character's body or something? Please help, thanks!


~ Masked_Beanie
Report Abuse
Thedagz is not online. Thedagz
Joined: 10 Mar 2012
Total Posts: 798
07 Jul 2017 12:13 PM
You might of clicked on the hat

so try this

if mouse.Target and mouse.Target.Parent:FindFirstChild("Humanoid") or mouse.Target.Parent.Parent:FindFirstChild("Humanoid") then
Report Abuse
Thedagz is not online. Thedagz
Joined: 10 Mar 2012
Total Posts: 798
07 Jul 2017 12:13 PM
also do print(mouse.Target) if it glitches so you can see what its clicking
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