bob354293
|
  |
| Joined: 26 Oct 2008 |
| Total Posts: 2609 |
|
|
| 06 Aug 2012 08:07 AM |
Right, i have 500 lines of script wrote, all working, now, all i need is, when it awards money, it only awards it if a value called 'Alive' is true, anyway, what i need is, if the player dies, it sets this value to false, so the game knows not to give this player money, im not very familiar with the player died function, so help please, thanks :)
all i need is the script, that changes the value to false if the player dies, ty :) |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 06 Aug 2012 08:09 AM |
From wiki:
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) for _, child in next, character:GetChildren() do if child:IsA('Humanoid') then child.Died:connect(function() Alive = false end) end end end)end) |
|
|
| Report Abuse |
|
|
bob354293
|
  |
| Joined: 26 Oct 2008 |
| Total Posts: 2609 |
|
|
| 06 Aug 2012 08:10 AM |
thankyou dude :) i must say, your pretty helpfull :) |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 08:11 AM |
use the event Died in the humanoid in the player
example: PlayerName = ""--the name on the player here game.Players[PlayerName].Character.Humanoid.Died:connect(function() --Stuffs to do end) |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 06 Aug 2012 08:11 AM |
A better structure:
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) for _, child in next, character:GetChildren() do if child:IsA('Humanoid') then child.Died:connect(function() Alive = false end) end end end) end) |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 08:11 AM |
| ops, I was too late to post. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 06 Aug 2012 08:12 AM |
| And your script isn't that good because it works for one specific person. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 08:13 AM |
| I know, it was only an example. |
|
|
| Report Abuse |
|
|
bob354293
|
  |
| Joined: 26 Oct 2008 |
| Total Posts: 2609 |
|
|
| 06 Aug 2012 08:18 AM |
| Thankyou people for the help :) just testing if it workies now >:P |
|
|
| Report Abuse |
|
|
bob354293
|
  |
| Joined: 26 Oct 2008 |
| Total Posts: 2609 |
|
|
| 06 Aug 2012 08:20 AM |
| why does alive.value not change to false when the character dies? Or does it only work in online mode? |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 06 Aug 2012 08:21 AM |
| Oh, is alive a BoolValue? So an object inside anywhere? Like the Player? If so, you got to change the path. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2012 08:22 AM |
| did you spell it "alive.value" or did you spell it "Alive.Value", lua is case-sensitive? |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 06 Aug 2012 08:23 AM |
For example if it would be inside Player (not recommended):
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) for _, child in next, character:GetChildren() do if child:IsA('Humanoid') then child.Died:connect(function() player:findFirstChild("Alive").Value = false --You just gotta get the right path here, then end) end end end) end)
I also hope it isn't a local value. |
|
|
| Report Abuse |
|
|
bob354293
|
  |
| Joined: 26 Oct 2008 |
| Total Posts: 2609 |
|
|
| 06 Aug 2012 08:30 AM |
huh? When player entered, it gets given a BoolValue called Alive, Alive.Value is true when entered, But if the player dies then it gets changed to false |
|
|
| Report Abuse |
|
|