So, I wanted to be able to spawn a player in a custom location without having to use a spawn part. So I tried to make it so that when your character spawns in you are teleported to a specefic CFrame. Which I did so using this:
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local humanoid = character:FindFirstChild("Humanoid")
character.Torso.CFrame=CFrame.new(0,50,0)+findBaseOf(player).Position
if humanoid then
humanoid.Died:connect(function()
wait(2)
character:Destroy()
wait(1)
player:LoadCharacter()
end)
end
end)
player:LoadCharacter()
end)
After trying that I got an error saying "attempt to index a nil value". So I figured the torso hadn't loaded into the character yet and I replaced the teleporting line(The line with the error) with this:
character:WaitForChild("Torso").CFrame=CFrame.new(0,50,0)+findBaseOf(player).Position
This however did not help and it still returned the same message. So my question is, how do you go about spawning players into a specific location or teleporting them when they spawn without getting that error?

7 comments
Please define what
findBaseofis.All you need to know is that it returns a part that is in workspace.
can you post the full error message? There should be a line on which the error was encountered..
11:49:27.942 - Workspace.PlayerHandler:33: attempt to index a nil value
I don't see how that helped though ImageLabel
Well line 33 is obviously not in the snippet you've provided so let us know exactly what the equivalent of line 33 is ....
Line 33 is in the snippet ... It's just not labeled as line 33. In the original question I said "I replaced the teleporting line(The line with the error)" though ...