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
 

OnTouch From something with out a humanoid

Previous Thread :: Next Thread 
Computermaster01 is online. Computermaster01
Joined: 29 May 2012
Total Posts: 369
08 Mar 2014 09:27 AM
If I do the basic method of:

script.Parent.Hit:connect(function(hit)

end)

But the thing that hit it is not an actual humanoid, for example a brick falls on top of it. Will it still run the function, or will it not?
Report Abuse
Marolex is not online. Marolex
Joined: 17 Dec 2012
Total Posts: 1785
08 Mar 2014 09:28 AM
Yes it will.
add this in after the function line

if hit.Parent:FindFirstChild("Humanoid") then
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
08 Mar 2014 09:32 AM
Do what Marolex said, but since you are using the touched event, I suggest adding a debounce.


Also, if you have non-player humanoids in your place, and you want the function to only run on the players, try this:


script.Parent.Hit:connect(function(hit)
local p = game.Players:GetPlayerFromCharacter(h.Parent)
if p then

--Do stuff here

end
end)
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