|
| 09 Sep 2013 09:40 PM |
Likes say I have a function like this
Game.Players.Scriptural.Character.Humanoid.HealthChanged:connect(function() print(Game.Players.Scriptural.Character.Humanoid.Health) end
That works fine, but what if my humanoid got removed, and I added in a new one, the script stops working because the humanoid I had it connected to is no longer there, so how would I auto reconnect the function the new humanoid if something like that happened? |
|
|
| Report Abuse |
|
|
Lapwn
|
  |
| Joined: 03 Jun 2012 |
| Total Posts: 5975 |
|
| |
|
|
| 09 Sep 2013 09:41 PM |
| No. I like using Game, and it works just as well as game. |
|
|
| Report Abuse |
|
|
pieshop97
|
  |
| Joined: 11 Mar 2011 |
| Total Posts: 550 |
|
|
| 09 Sep 2013 09:46 PM |
| Clone the deleted humanoid. DERP |
|
|
| Report Abuse |
|
|
| |
|
Lapwn
|
  |
| Joined: 03 Jun 2012 |
| Total Posts: 5975 |
|
|
| 09 Sep 2013 09:48 PM |
m=game.Players.Scriptural.Character. m.Humanoid.HealthChanged:connect(function() print(m.Humanoid.Health) end
f=m:Clone() f.Parent=m |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2013 09:49 PM |
| Thats not what I asked at all, I'm not sure what you are doing. Thanks for trying, I'm not really sure how to explain what I need. |
|
|
| Report Abuse |
|
|
chaokid9
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 6187 |
|
|
| 09 Sep 2013 09:50 PM |
while wait() do x = Game.Players.Scriptural.Character end x.Humanoid.HealthChanged:connect(function() print(x.Humanoid.Health) end
That should do it. This way it is constantly updating the character. |
|
|
| Report Abuse |
|
|
Lapwn
|
  |
| Joined: 03 Jun 2012 |
| Total Posts: 5975 |
|
|
| 09 Sep 2013 09:50 PM |
oh I get it
for _,v in pairs(game.Players.LocalPlayer) do if v.Name=="Scriptual" then v.Character.Humanoid.HealthChanged:connect(function() print(v.Character.Humanoid.Health) end |
|
|
| Report Abuse |
|
|
Lapwn
|
  |
| Joined: 03 Jun 2012 |
| Total Posts: 5975 |
|
| |
|
|
| 09 Sep 2013 09:53 PM |
@Chao The only problem with that is it will connect the function more than once |
|
|
| Report Abuse |
|
|
chaokid9
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 6187 |
|
| |
|
pieshop97
|
  |
| Joined: 11 Mar 2011 |
| Total Posts: 550 |
|
|
| 09 Sep 2013 09:54 PM |
I'll explain what I meant then...
Okay, so DON'T add a new humanoid, before you delete the humanoid in the first place, make it where it clones the humanoid after it is deleted, therefore making the script function correct because the humanoid is still there, just cloned. |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2013 09:57 PM |
while wait(0.03) do --Stuff I'm too lazy to type out that connects the function end
That would connect the function every 0.03 seconds
@Pie What I need is for if the humanoid gets removed for some reason, not a currently known one, it will automaticly connect it to the new humanoid. |
|
|
| Report Abuse |
|
|
chaokid9
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 6187 |
|
|
| 09 Sep 2013 09:59 PM |
| Yeah, but it is not in the 'while wait() do' it is completely separate. Maybe you are right, but it looks fine to me. |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2013 10:00 PM |
| Oh I see, well in that case it would never connect the function at all |
|
|
| Report Abuse |
|
|
chaokid9
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 6187 |
|
|
| 09 Sep 2013 10:02 PM |
| Why not? If that is true and worst comes to worst you could just use tow scripts and a physical variable. |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2013 10:04 PM |
while wait(0.03) do --Forever loop --Blah blah set variable end --Ends loop, that will always repeat, so what is below doesn't matter --Connect function, but this part will never run because of the loop. |
|
|
| Report Abuse |
|
|
lucas668
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 6183 |
|
|
| 09 Sep 2013 10:10 PM |
p = Game.Players.Scriptural con;
function Connector(humanoid)
if humanoid:IsA("Humanoid") then
con = nil
con = humanoid.HealthChanged:connect(function(newhealth) print(newhealth) end)
end end
p.CharacterAdded:connect(function() if p.Character:FindFirstChild("Humanoid") then Connector(p.Character.Humanoid) end end)
|
|
|
| Report Abuse |
|
|