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: How would I detect...

Previous Thread :: Next Thread 
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
30 Nov 2012 03:50 PM
How would I detect when one players bumps into and touches another player?

Would I just run a .Touched event on their character, or in their torso? Is there anything special I would need to do?
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
30 Nov 2012 03:51 PM
just a .Touched event in the torso, or create a Region3 around the character.
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
30 Nov 2012 03:52 PM
or check .magnitude, but that would be really nasty and inefficient.
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
30 Nov 2012 03:57 PM
Would it run in the character? Can you touch the character, or must it be a specific part (such as the torso)?
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
30 Nov 2012 04:00 PM
Dude, it's just a .Touched event.
You can connect it to every part in the character

for i, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v.className =="Part" then
v.Touched:connect(function(h)

-- stuff

end)
end
end


put this in a localscript in starterGui
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
30 Nov 2012 04:03 PM
I know, I'll probably end up doing that. My question was could I do:

game.Players.NeonBlox.Character.Touched:connect(function(p)
--code
end)

or must I iterate through every part?
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
30 Nov 2012 04:04 PM
no you can't do that. You have to iterate through character:GetChildren()
Report Abuse
NeonBlox is not online. NeonBlox
Joined: 19 Oct 2008
Total Posts: 1462
30 Nov 2012 04:06 PM
Thanks. :)
Report Abuse
iBrilliance is not online. iBrilliance
Joined: 19 Oct 2012
Total Posts: 1032
30 Nov 2012 04:13 PM
Well not all of the children of character are things that can be touched, so that is why you have to be more selective and iterate through the children, to verify that the thing you are detecting if it is touched, can actually be touched.
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