✓ Accepted answer
There is a reason why there are StarterPlayerScripts and StarterCharacterScripts in your Roblox Studio. It takes a few seconds to load the character after the player has joined. The more assets (models, parts, etc) you have in your game, the longer it will take for everything to load, especially if the assets are not cached (players joining for the first time)
You can use the player.CharacterAdded event to wait for the character to spawn.
Also use PlayerAdded instead of ChildAdded
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
print("Character added")
end)
end)
I'm not sure why but the actual teleport didn't work for me. But you shouldn't be doing this either way, you should use SpawnLocations and Teams for this.
You can also just save the last touched spawnlocation's position. Check out the Obby template in Roblox Studio. It saves the positions but to make it work you need to save it to a DataStore and also read it when a player joins.(credits to the deleted user commenting under this post)
Just use a DataStore, there are great tutorials out there. This one is from AlvinBlox
1 comment
Is this in a Local Script or a Script?