alty1234
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 13 |
|
|
| 30 Jul 2014 10:42 AM |
Say I have a player's name which I am storing under the variable "playerName". How would I obtain the torso of said character using the parent/child ssytem? I've tried the below code, which does not work:
local playerTorso = game.Players.playerName.Character:FindFirstChild("Torso")
Thanks in advance. |
|
|
| Report Abuse |
|
|
|
| 30 Jul 2014 11:59 AM |
This is a question for Scripting Helpers, but if playerName is a string then you might try:
game.Players[playerName].Character:FindFirstChild("Torso") |
|
|
| Report Abuse |
|
|
alty1234
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 13 |
|
|
| 01 Aug 2014 05:15 AM |
Ok, so I've gone and replaced that line from my previous post with:
local playerTorso = game.Players[playerName].Character:FindFirstChild("Torso")
which is then returning this error message in the output window:
Workspace.TargetA.ProximityRing.Script:44: bad argument #2 to '?' (string expected, got userdata)
Based on this, do I need to convert playerName into a String data type first? Cos I'm printing playerName (using print(playerName)) into the output window in the line before this in order to check it holds the correct name, and I thought youcould only print number values and strings into the output window. |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2014 06:59 AM |
| playerName should be a string already, assuming you did it right. Are you sure you're setting playerName equal to the player's name, and not the player itself? |
|
|
| Report Abuse |
|
|
alty1234
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 13 |
|
|
| 03 Aug 2014 08:32 AM |
| Yeah, you were right, I looked into the part of the script that was assigning the value to "playerName" and found that it was assigning the player itself. I've fixed it now. Thanks! |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2014 02:52 PM |
| No problem, glad I could be of help. |
|
|
| Report Abuse |
|
|