spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 19 Aug 2017 08:04 PM |
Note: i didn't make this, no errors but its not injuring anyone.
for i,v in pairs(game.Players:GetChildren()) do local Char = v.Character if Char then local Torso = v:FindFirstChild("HumanoidRootPart") if Torso then local dist = (Torso.Position - ExplosionPart.Position).magnitude if dist <= 100 then v.Parent:FindFirstChild("Humanoid"):TakeDamage((Level.Value * 2) + 25) end; end; end; end;
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 19 Aug 2017 08:08 PM |
"v.Parent:FindFirstChild("Humanoid"):TakeDamage(hashtags)"
v is a player, this reads:
player.Parent.Humanoid:TakeDamage(damage formula)
If you ran this, this would absolutely error unless there exists an object such that game.Players.Humanoid is a valid path |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
| |
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 19 Aug 2017 08:10 PM |
Didn't catch that, it didn't error cause of FindFirstChild()
|
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 19 Aug 2017 08:13 PM |
This didn't work either.
for i,v in pairs(game.Players:GetChildren()) do local Char = v.Character if Char then local Torso = v:FindFirstChild("HumanoidRootPart") if Torso then local dist = (Torso.Position - ExplosionPart.Position).magnitude if dist <= 100 then v.Character:FindFirstChild("Humanoid"):TakeDamage((Level.Value * 2) + 25) end; end; end; end;
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 19 Aug 2017 08:14 PM |
Except it absolutely does. FindFirstChild returns one of two things: the object it found or nil
If we assume that game.Players.Humanoid is not a valid path, v.Parent:FindFirstChild("Humanoid"):TakeDamage(damage formula)
Evaluates to
(nil):TakeDamage(damage formula)
Which errors.
You can easily test this in the commandline
print(game:FindFirstChild("Casulist's imaginary friend, Steve").Name) |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 19 Aug 2017 08:16 PM |
| If we are to believe that what you originally posted didn't error, then we must conclude it never ran to begin with (which explains why it still isn't working now). |
|
|
| Report Abuse |
|
|
|
| 19 Aug 2017 08:16 PM |
Try local Torso = Char:FindFirstChild("HumanoidRootPart")
Instead Of local Torso = v:FindFirstChild("HumanoidRootPart") |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 19 Aug 2017 08:17 PM |
I removed the FindFirstChild() and just did v.Character.Humanoid and i still got no errors.
|
|
|
| Report Abuse |
|
|
|
| 19 Aug 2017 08:18 PM |
| Try using print to see which part of the script isn't responding |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 19 Aug 2017 08:19 PM |
Oh, missed that too, now its working, ty guys for the help.
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 19 Aug 2017 08:19 PM |
| Tiny is correct, and if that doesn't fix it, then it's safe to assume the whole snippet is never actually ran. |
|
|
| Report Abuse |
|
|