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?
--That might be impossible. You can't really CFrame something then place a script for you to teleport to there when you spawn. --Use a regular spawn point.
It looks to me like either the function "findBaseOf()" is returning nil or the ".Position" value, of whatever "findBaseOf()" is returning, is nil. I could give better input if you told me exactly what "findBaseOf()" is and what it consists of. I have to give this comment as an answer because I can't comment on any of the posts.