01 | function Touch() |
02 |
03 | game.Workspace.Player [ "Right Arm" ] :Destroy() |
04 | wait( 1 ) |
05 | game.Workspace.Player [ "Left Arm" ] :Destroy() |
06 | wait( 1 ) |
07 | game.Workspace.Player [ "Left Leg" ] :Destroy() |
08 | wait( 1 ) |
09 | game.Workspace.Player [ "Right Leg" ] :Destroy() |
10 | wait( 4 ) |
11 | game.Workspace.Player [ "Head" ] :Destroy() |
12 |
13 | end |
14 |
15 | script.Parent.Touched:connect(Touch) |
Be aware I just started working with more complex Player scripts. I'm sure it's something obvious I'm missing, but I can't seem to find it.
You're always destroying the body parts of the same model - Player
. What if there is no Player inside of workspace? You have to reference the character according to what the Touched
event returns. The Touched event returns whatever was touched.
01 | function Touch(hit) |
02 | --Make sure it's a player |
03 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
04 | char = hit.Parent |
05 | char [ "Right Arm" ] :Destroy() |
06 | wait( 1 ) |
07 | char [ "Left Arm" ] :Destroy() |
08 | wait( 1 ) |
09 | char [ "Left Leg" ] :Destroy() |
10 | wait( 1 ) |
11 | char [ "Right Leg" ] :Destroy() |
12 | wait( 4 ) |
13 | char [ "Head" ] :Destroy() |
14 | end |
15 | end |
16 |
17 | script.Parent.Touched:connect(Touch) |
Note: The character will die upon the removal of the 'Head' instance.