TomsTown
|
  |
| Joined: 27 Dec 2010 |
| Total Posts: 452 |
|
|
| 06 Jul 2015 02:42 PM |
Heyy, im trying to make a block that damages the health of my car touches it
I have a variable in the car that is called hp and when this reaches 0 it will explode the car
However how can I link the block and the damage to the car together?
like ontouch, if car then hp.value == -5??
Please can anyone help Thankyou TomsTown |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 06 Jul 2015 02:51 PM |
script.Parent.Touched(function(crash) crash.Parent.HP.Value = crash.Parent.HP.Value -5 end)
I assume your car parts are in a model and not anywhere deeper in model (model that is in a model).
~davisky~ |
|
|
| Report Abuse |
|
|
VuItured
|
  |
| Joined: 28 Jun 2015 |
| Total Posts: 52 |
|
|
| 06 Jul 2015 02:54 PM |
idk if this works im on my ipad so idk
debounce = false function onTouch(part) if debounce == false then local humanoid = part.Parent:FindFirstChild("Health") if (humanoid ~= nil) then debounce = true humanoid.Value = humanoid.Value - 50 wait(2) debounce = false end end end
script.Parent.Touched:connect(onTouch)
remember idk if it works
where my cookie |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 06 Jul 2015 02:55 PM |
Oh right, forgot to add debounce.
~davisky~ |
|
|
| Report Abuse |
|
|
|
| 06 Jul 2015 03:20 PM |
script.Parent.Touched:connect(function(plr) if plr.Parent:findFirstChild("humanoid") then plr.Parent.humanoid.Health = 0 end end)
-TheSubatomicalWorld |
|
|
| Report Abuse |
|
|
VuItured
|
  |
| Joined: 28 Jun 2015 |
| Total Posts: 52 |
|
|
| 06 Jul 2015 09:16 PM |
Did mine work for you?
where my cookie |
|
|
| Report Abuse |
|
|