|
| 11 Feb 2012 04:21 PM |
I'm writing the script for a leaderboard, and I need to know which is a better method for an onPlayerRespawn function:
player.Changed:connect(...)
or
onPlayerRespawned(...) player.CharacterAdded:connect(...) |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2012 04:21 PM |
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character)
end) end) |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2012 04:23 PM |
| So...I take from your lack of answering my question the best way would be to initiate a CharacterAdded event at the start of the PlayerAdded event? |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 11 Feb 2012 04:54 PM |
| CharacterAdded is the best way. |
|
|
| Report Abuse |
|
|
noobkid
|
  |
| Joined: 17 Sep 2007 |
| Total Posts: 649 |
|
|
| 11 Feb 2012 04:58 PM |
You could use, Player.Changed:connect(function(Character) if Player.Character~=nil then --respawn else --death end end) |
|
|
| Report Abuse |
|
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 11 Feb 2012 04:59 PM |
I prefer CharacterAdded. .Changed is fired when the 'properties' changed. You don't want it to fire when the Player's property such as "TeamColor", "AccountAge",ect.
|
|
|
| Report Abuse |
|
|
noobkid
|
  |
| Joined: 17 Sep 2007 |
| Total Posts: 649 |
|
|
| 11 Feb 2012 05:03 PM |
@Phellem, You should do a research about it before you post, this is an example which only fires when the Value property is changed; Instance.new('ObjectValue',workspace).Changed:connect(function(Value) Print 'the value property is changed' end) |
|
|
| Report Abuse |
|
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 11 Feb 2012 05:14 PM |
http://wiki.roblox.com/index.php/Changed
game.Players.Phellem.Changed:connect(function(change) print("Player's " ..change..' has been changed') end)
|
|
|
| Report Abuse |
|
|
noobkid
|
  |
| Joined: 17 Sep 2007 |
| Total Posts: 649 |
|
|
| 11 Feb 2012 05:19 PM |
@Phellem That doesn't prove anything, my script works. Try it before you post again. |
|
|
| Report Abuse |
|
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 11 Feb 2012 05:27 PM |
"I prefer CharacterAdded. .Changed is fired when the 'properties' changed. You don't want it to fire when the Player's property such as "TeamColor", "AccountAge",ect. [changed]"
Then I proved to you that when an object's property changed, it fired. Also, I know your code works.
"You should do a research about it before you post, this is an example which only fires when the Value property is changed"
I did do research before posting. I don't know why you're so exasperated. |
|
|
| Report Abuse |
|
|
noobkid
|
  |
| Joined: 17 Sep 2007 |
| Total Posts: 649 |
|
|
| 11 Feb 2012 05:30 PM |
| While using a valid property of the object as an argument it only effects when the certain property is changed. |
|
|
| Report Abuse |
|
|
Phellem
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 1984 |
|
|
| 11 Feb 2012 05:38 PM |
Your point was?
My first statement I've posted was correct.
|
|
|
| Report Abuse |
|
|
|
| 11 Feb 2012 05:42 PM |
| I see this is a much-disputed subject. |
|
|
| Report Abuse |
|
|
noobkid
|
  |
| Joined: 17 Sep 2007 |
| Total Posts: 649 |
|
|
| 11 Feb 2012 05:44 PM |
@Phellem, You should understand my point from that, I'm not going to explain it again. |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2012 05:50 PM |
Scripts execute procedurally:
object.Changed:connect(
The computer reads this and when 'object' is changed in anyway, it goes to the next part:
function(property)
This the function the event calls when 'object' is changed. 'property' IS NOT SPECIFIED HERE. This is the key that contains the property that is changed, which is passed by the event.
if property == "Character" then
This tells us if the property is what we want, if so, go on, if not, skip this.
end end)
This is self-explanatory
So, in conclusion, .Changed is called whenever a property is changed, no matter what property it is. I don't remember whose side this is for though... |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2012 05:51 PM |
| I think I just answered my own question... |
|
|
| Report Abuse |
|
|
noobkid
|
  |
| Joined: 17 Sep 2007 |
| Total Posts: 649 |
|
|
| 11 Feb 2012 06:00 PM |
@soc, You're not reading my posts..
Lrn2scrpt |
|
|
| Report Abuse |
|
|