|
| 27 Dec 2013 10:23 AM |
Well, so I figured out a little bit more about functions in that you can also tie them to an event for a function to happen when an event is fired, and from that I was able to figure out how to make something happen when a part is touched.
However, I still need to know how to identify the player/object that is touching the part. From the identification I can gather how to kill the player (removing the torso), and a few more things I need to do.
But I'm still stuck on how to figure out who touched the part. can somebody help me out? |
|
|
| Report Abuse |
|
|
Orced
|
  |
| Joined: 08 Apr 2010 |
| Total Posts: 1301 |
|
|
| 27 Dec 2013 10:34 AM |
function touch(hit) -- hit is a variable of what has touched your brick check = hit.Parent:FindFirstChild('Humanoid') if check then char = check.Parent -- character in workspace player = game.Players:FindFirstChild(char.Name) -- player (Backpack, PlayerGui) if char and player then -- to make sure 100%
char.Torso:remove() end -- check end end -- final check end end -- function end script.Parent.Touched:connect(touch) -- what has to be touched |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 10:34 AM |
I think you were the one who nicely commented my game..
function onTouched(hit) hit.Parent:FindFirstChild("Humanoid") Like this? Hit in the (), hit.Parent:FindFirstChild("Item") or... clone something to hit.Parent
hit.Parent is the player. |
|
|
| Report Abuse |
|
|
Orced
|
  |
| Joined: 08 Apr 2010 |
| Total Posts: 1301 |
|
|
| 27 Dec 2013 10:36 AM |
| Your way may glitch. For Ex. if a sword has touched the brick, most likely the script will crash |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 10:40 AM |
Good point, something like...
if hit.Parent:FindFirstChild("Humanoid") then
|
|
|
| Report Abuse |
|
|
Orced
|
  |
| Joined: 08 Apr 2010 |
| Total Posts: 1301 |
|
|
| 27 Dec 2013 10:59 AM |
| Yeah, but it's more advanced to use variables. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 12:36 PM |
human = hit.Parent:FindFirstChild("Humanoid") if human then
?? |
|
|
| Report Abuse |
|
|