I have attempted to use types of wait codes? like WaitForChild, Repeat Wait() Until, others but still get a nil error, by having such a long wait the player spawns in the air.
game.Players.PlayerAdded:Connect(function(Player) wait(1) -- this is the only wait that work game.Players:FindFirstChild(Player.Name).Character.LowerTorso.CFrame = CFrame.new(game.Workspace.Spawn.Position) + Vector3.new(0, 3, 0) print(Player.Name.." Test") end)
What ihatecars100 said is one of way of doing it, another would be as follows:
game.Players.PlayerAdded:Connect(function(Player) -- PlayerAdded Event! Player.CharacterAdded:Connect(function(Character) -- Make an anonymous characteradded function! Character.LowerTorso.CFrame = CFrame.new(game.Workspace.Spawn.Position) + Vector3.new(0, 3, 0) print(Player.Name, "Character has loaded!") -- even though character model and player object share the same name end) print(Player.Name, "has loaded!") end)
Ah yes, this is a problem plenty of people have trouble with when starting.
This can be fixed by using the ‘player.CharacterAdded’ Event with wait().
game.Players.PlayerAdded:Connect(function(Player) local char = Player.Character or Player.CharacterAdded:wait() char.LowerTorso.CFrame = CFrame.new(game.Workspace.Spawn.Position) + Vector3.new(0, 3, 0) print(Player.Name.." Test") end)