Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 08 Dec 2013 08:29 PM |
I know it would go something like this, but I want it to only explode after it's been hit four times.. How would I do that? This is what I have.
local s = script.Parent:GetChildren() s.Touched:connect(function(hit) if hit.Name=="Bullet" then local e = Instance.new("Explosion") e.Parent = script.Parent.Head wait(.1) script.Parent:BreakJoints()
If you're wondering, there is a humanoid and a head inside the model. What I don't understand is how to make it get hit four times until it explodes.
Strength, Honor, Glory. Hail Puternic Imperium! |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 08 Dec 2013 08:30 PM |
local s = script.Parent:GetChildren() local hit = 0;
s.Touched:connect(function(hit) if hit.Name=="Bullet" then if hit < 4 then hit = hit + 1 return elseif hit == 3 then hit = 0 local e = Instance.new("Explosion") e.Parent = script.Parent.Head wait(.1) script.Parent:BreakJoints() end |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 08 Dec 2013 08:33 PM |
Make each bullet do 25 dmg, and then
script.Parent.Humanoid.Died:connect(function() exp=Instance.new("Explosion", script.Parent.Head) exp.Position = script.Parent.Head.Position end) |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 08 Dec 2013 08:33 PM |
21:31:10.816 - Workspace.Model.ExpScript.Script:4: attempt to index field 'Touched' (a nil value) Line 4.
I think it's because Touched isn't a property of some of the things that I have in the model. How will I make it only touched for the touchable parts?
Strength, Honor, Glory. Hail Puternic Imperium! |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 08 Dec 2013 08:35 PM |
Ah, I just realized you did it completely wrong.
local s = script.Parent:GetChildren() local hit = 0;
for i,v in pairs(s) do if v:IsA([==[BasePart]==]) then v.Touched:connect(function(hit) if hit.Name=="Bullet" then if hit < 4 then hit = hit + 1 return elseif hit == 3 then hit = 0 local e = Instance.new("Explosion") e.Parent = script.Parent.Head wait(.1) script.Parent:BreakJoints() end -- all your ends here end |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 08 Dec 2013 08:38 PM |
No errors, but it doesn't seem to work.
Strength, Honor, Glory. Hail Puternic Imperium! |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 08 Dec 2013 08:42 PM |
"if hit < 4 then"
Change that to < 3 |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 08 Dec 2013 08:44 PM |
Workspace.Model.Model.ExpScript:8: attempt to compare userdata with number 21:42:29.235 - Script 'Workspace.Model.Model.ExpScript', Line 8 21:42:29.236 - stack end
Strength, Honor, Glory. Hail Puternic Imperium! |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 08 Dec 2013 08:45 PM |
mmm
local s = script.Parent:GetChildren() local hit_ = 0;
for i,v in pairs(s) do if v:IsA([==[BasePart]==]) then v.Touched:connect(function(hit) if hit.Name=="Bullet" then if hit_ < 4 then hit_ = hit_ + 1 return elseif hit_ == 4 then hit_ = 0 local e = Instance.new("Explosion") e.Parent = script.Parent.Head wait(.1) script.Parent:BreakJoints() end -- all your ends here end |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 08 Dec 2013 08:48 PM |
Now it doesn't do anything.
Strength, Honor, Glory. Hail Puternic Imperium! |
|
|
| Report Abuse |
|
|