How to fix the error: "Attempt to index a nil value"? Help please.
01 | m = Instance.new( "Message" ) |
02 | h = Instance.new( "Hint" ) |
03 | m.Parent = game.Workspace |
04 | h.Parent = game.Workspace |
06 | if game.Players.NumPlayers = = 1 then |
07 | m.Text = "Loading-Please wait." |
09 | Spawns = game.Workspace.Elevator.ElevatorSpawn:GetChildren() |
10 | Spawnz = game.Workspace.LobbySpawn:GetChildren() |
11 | m.Text = "Teleporting to Elevator" |
13 | for i, v in pairs (game.Players:GetPlayers()) do |
15 | check = game.Workspace:FindFirstChild(name) |
17 | checkHumanoid = check:FindFirstChild( "Humanoid" ) |
19 | check:MoveTo(Spawns [ 1 ] .Position) |
Whenever I run this script the output states: attempt to index field '?' (a nil value)
. The line it is having the error is the line that says: check:MoveTo(Spawns[1].Position)
. It doesn't seem to be recognizing "Spawns" as a variable. In the variables of Spawns and Spawnz the ElevatorSpawn and LobbySpawn are both models, each containing 10 parts inside of them.