Torush1
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 47 |
|
|
| 15 Jan 2016 09:45 PM |
Script:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) local PlayerFolders = game.Workspace.Players local RedTeam = PlayerFolders.Red local BlueTeam = PlayerFolders.Blue local Neutral = PlayerFolders.Neutral local Humanoid = character:FindFirstChild("Humanoid") Humanoid.JumpPower = 0 local PlayerModel = game.Workspace:FindFirstChild(character.Name) PlayerModel.Parent = Neutral end) end)
Output Problem: 13:39:35.675 - ServerScriptService.Script:36: attempt to index local 'PlayerModel' (a nil value) 13:39:35.676 - Stack Begin 13:39:35.676 - Script 'ServerScriptService.Script', Line 36 13:39:35.676 - Stack End
Can anyone please find a way to fix this please? Cheers. |
|
|
| Report Abuse |
|
|
sayhisam1
|
  |
| Joined: 25 Nov 2009 |
| Total Posts: 2092 |
|
|
| 15 Jan 2016 09:52 PM |
There is no playermodel that exists for the given character. You should add an if statement that checks if the PlayerModel exists
local PlayerModel = game.Workspace:FindFirstChild(character.Name) if PlayerModel then PlayerModel.Parent = Neutral end
|
|
|
| Report Abuse |
|
|
Torush1
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 47 |
|
|
| 15 Jan 2016 09:55 PM |
| The 'if' statement is false. Any other way I can localise game.Workspace.Player1 ? |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2016 09:59 PM |
local PlayerModel = character
playermodel was already defined as character
|
|
|
| Report Abuse |
|
|
Torush1
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 47 |
|
|
| 15 Jan 2016 10:02 PM |
| It's localising the same model, ergo doesn't make a difference. |
|
|
| Report Abuse |
|
|
Torush1
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 47 |
|
|
| 15 Jan 2016 10:17 PM |
So this bit has been added to the end of the script:
if PlayerModel ~= nil then print("Working") PlayerModel.Parent = Neutral end
__________
The message prints but the Player1 model isn't relocated. Player1 has been defined as PlayerModel. Is it even possible for the Player1 model to be relocated to have a different parent? |
|
|
| Report Abuse |
|
|
Torush1
|
  |
| Joined: 04 Feb 2011 |
| Total Posts: 47 |
|
|
| 15 Jan 2016 10:33 PM |
| I've decided to make an Instance.new script to insert a StringValue into the "Neutral" model. Thanks for the help guys. Cheers. |
|
|
| Report Abuse |
|
|