|
| 19 Jan 2013 09:51 AM |
i need help on a script that when a car has 0 health it doesnt move anymore it just stays still as if it is anchored or if this script is changable for remove the car but still alow its regenability that would be good also
h = script.Parent.Humanoid
while true do if h.Health > 0 then h.Health = h.Health elseif h.Health < 1 then script.Parent.VehicleSeat.Disabled = true end end
-------------------------OR-------------------------
h = script.Parent.Humanoid s = script.Parent.Head
while true do if h.Health > 0 then h.Health = h.Health elseif h.Health <1 then s.Anchored = true end end
-----------------------OR----------------------------
h = script.Parent.Humanoid
while true do if h.Health > 0 then h.Health = h.Health elseif h.Health <1 then script.Parent:remove() end end |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 19 Jan 2013 09:54 AM |
I'd use a .Changed, so you're not causing lag.
local life = script.Parent.Humanoid life.Changed:connect(function() if life.Health > 0 then return end if life.Health <= 0 then script.Parent:Destroy() --or w/e you want to use here. end end end) |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 19 Jan 2013 09:55 AM |
--edit
local life = script.Parent.Humanoid life.Changed:connect(function() if life.Health > 0 then return end if life.Health <= 0 then script.Parent:Destroy() --or w/e you want to use here. end end) |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2013 10:04 AM |
unfortunately didnt work
output said need ")" to close "(" on line 2 ? but it looks like it is closed so the car didnt destroy it just acted as it normally does |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 19 Jan 2013 10:07 AM |
| Use the one that says "--edit". |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 19 Jan 2013 10:08 AM |
lol, extra end
His script should work.
"If you want to become a Developer or Innovator for CSA, contact me." |
|
|
| Report Abuse |
|
|
| |
|