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 » Scripting Helpers
Home Search
 

Re: Model isn't being destroyed

Previous Thread :: Next Thread 
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
18 Feb 2013 05:50 PM
if script.Parent.Humanoid.Health == 0 then
script.Parent:Destroy()
end

script.Parent is the model
script.Parent.Humanoid is the humanoid in the model
There is also a head inside of the model
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
18 Feb 2013 05:53 PM
if script.Parent.Humanoid.Health == 0 then print("line one")
script.Parent:Destroy() print("line 2")
end print("line 3")

post the output
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
18 Feb 2013 05:56 PM
Nothing printed
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
18 Feb 2013 06:05 PM
script.Parent.Humanoid.Died:connect(function() game.Debris:AddItem(script.Parent,2) end)


Assuming this is what You want.

What you posted won't work because it fires when the Character loads, and the Health wouldn't be 0, it never rechecks.
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
18 Feb 2013 06:29 PM
@the

I'll try that, thanks for the tip
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
18 Feb 2013 06:31 PM
@the

Didn't work
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
18 Feb 2013 06:33 PM
while wait() do
if script.Parent.Humanoid.Health <= 0 then
script.Parent:Destroy()
end
end
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
18 Feb 2013 06:34 PM
Xnites worked.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
18 Feb 2013 06:36 PM
The horror...a while loop D:


script.Parent.Humanoid.HealthChanged:connect(function(floaty)
if floaty <= 0 then
script.Parent:Destroy()
end
end)
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
18 Feb 2013 06:36 PM
@not

lololol.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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