|
| 19 Dec 2016 01:08 PM |
tool.Handle.Touched:connect(function(hit) if hit.Name == "Head" or "Torso" or "Right Arm" or "Left Arm" or "Right Leg" or "Left Leg" then local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.Health = 0 end end end)
14:07:47.724 - Script 'Players.Player1.Backpack.Knife.Script', Line 24 14:07:47.724 - Stack End 14:07:47.744 - Players.Player1.Backpack.Knife.Script:24: attempt to index field 'Parent' (a nil value) 14:07:47.745 - Stack Begin 14:07:47.746 - Script 'Players.Player1.Backpack.Knife.Script', Line 24 14:07:47.746 - Stack End
Parent isn't a nil value.
|
|
|
| Report Abuse |
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 19 Dec 2016 01:56 PM |
What's happening here is you have an invalid if statement.
Unfortunately, Lua doesn't allow you to use syntax such as this.
You have to rewrite all of it by doing,
if hit.Name == "Head" or hit.Name == "Left Leg" --so on
What happens is, since the hit's name isn't Head, it goes on to your next check, which is "or "Left Leg""
And in this case, this is a non-nil string, so it passes through the if statement, however, the parent is nil. So that's why this is not working. Hope it helps! |
|
|
| Report Abuse |
|
|
| 19 Dec 2016 01:59 PM |
tool.Handle.Touched:connect(function(hit) if hit.Name == "Head" or hit.Name == "Torso" or hit.Name == "Right Arm" or hit.Name == "Right Leg" or hit.Name == "Left Arm" or hit.Name == "Left Leg" then local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.Health = 0 end end end)
|
|
|
| Report Abuse |
|