So I have this code that theoretically teleports the players in the lobby into the block part on the race track when the race cars are created and the race is ready to start.
local lobbySpawn = game.Workspace.LobbySpawn local trackSpawn = game.Workspace.TrackSpawn function teleportPlayers(target) for _, players in pairs(game.Players:GetChildren()) do local character = player.Character local torso = character.Torso torso.CFrame = target.CFrame end end teleportPlayers(trackSpawn)
I get this error:
attempt to index global 'player' (a nil value)
Your reference to the current iteration is players. You used player.
Change it to player and you should be good.
local lobbySpawn = workspace.LobbySpawn local trackSpawn = workspace.TrackSpawn function teleportPlayers(target) for _, player in pairs(game.Players:GetChildren()) do --'player' local character = player.Character local root = character:WaitForChild("HumanoidRootPart") root.CFrame = target.CFrame end end teleportPlayers(trackSpawn)