attempt to index nil with 'HumanoidRootPart' ?
I Want players in a table to teleport in a specific position. But, the output says that HumanoidRootPart Is Nil.
And I have made a table and saw,
[1] = Brioche_Noodle
[2] = "*** cycle table reference detected ***"
Function That I am focusing on,
02 | local Maps = Storage.Maps:GetChildren() |
03 | chosenMap = Maps [ math.random( 1 , #Maps) ] |
06 | chosenMap.Parent = workspace.Map |
09 | for _, player in ipairs (Playing) do |
12 | player.Character.HumanoidRootPart.Position = Vector 3. new(chosenMap.Teleporter.Position) |
Here is my whole script.
01 | local Players = game:GetService( "Players" ) |
02 | local Teams = game:GetService( "Teams" ) |
03 | local Storage = game:GetService( "ServerStorage" ) |
11 | Infected = Teams.Infected, |
12 | Citizens = Teams.Citizens |
14 | local gameStarted = false |
17 | local function onPlayerAdded(player) |
18 | print (player.Name .. " || Joined || " ) |
20 | if gameStarted = = false then |
21 | print (player.Name .. " is added to The Playing Table" ) |
23 | table.insert(Playing, player) |
26 | print (player.Name .. " is added to The Not Playing Table" ) |
28 | table.insert(NotPlaying, player) |
31 | player.Team = Team.Lobby |
36 | local function addPlayerToPlaying() |
37 | local AllPlayers = Players:GetPlayers() |
39 | table.insert(Playing, Playing) |
42 | local function addPlayerToNotPlaying() |
43 | local AllPlayers = Players:GetPlayers() |
45 | table.insert(NotPlaying, Playing) |
49 | local Maps = Storage.Maps:GetChildren() |
50 | chosenMap = Maps [ math.random( 1 , #Maps) ] |
53 | chosenMap.Parent = workspace.Map |
56 | for _, player in ipairs (Playing) do |
59 | player.Character.HumanoidRootPart.Position = Vector 3. new(chosenMap.Teleporter.Position) |
66 | local Maps = Storage.Maps:GetChildren() |
67 | chosenMap.Parent = nil |
69 | for _, player in ipairs (Playing) do |
71 | player.CharacterAdded:Connect( function (Character) |
72 | Character.HumanoidRootPart.Position = Vector 3. new(chosenMap.Lobby.Teleporter.Position) |
81 | Players.PlayerAdded:Connect(onPlayerAdded) |