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 » Scripters
Home Search
 

Re: Why isn't this working

Previous Thread :: Next Thread 
spinywind is not online. 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 is not online. 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 is not online. spinywind
Joined: 26 Jan 2012
Total Posts: 3580
19 Aug 2017 08:09 PM
oh, thx


Report Abuse
spinywind is not online. 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 is not online. 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 is not online. 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 is not online. 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
TinyGravity is not online. TinyGravity
Joined: 30 Apr 2016
Total Posts: 262
19 Aug 2017 08:16 PM
Try
local Torso = Char:FindFirstChild("HumanoidRootPart")

Instead Of
local Torso = v:FindFirstChild("HumanoidRootPart")
Report Abuse
spinywind is not online. 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
TinyGravity is not online. TinyGravity
Joined: 30 Apr 2016
Total Posts: 262
19 Aug 2017 08:18 PM
Try using print to see which part of the script isn't responding
Report Abuse
spinywind is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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