I am trying to teleport players that join the game to a certain spawnpoint, I've been looking how to do it but I can't find anything that I understand.
Here is my code:
local LobbySpawnLocations = workspace:FindFirstChild("LobbySpawnLocations")
local LobbySpawnPoints = LobbySpawnLocations:GetChildren()
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if player then
player.Character.HumanoidRootPart.CFrame = game.Workspace.LobbySpawnLocations.LobbySpawn.CFrame + Vector3.new(0,5,0)
else
end
end)
Thanks :)

4 comments
use SetPrimaryPartCFrame instead of directly modifying the HRP's cframe, which only changes the cframe of the HRP and nor the rest of the character
Also, the if statement isn't needed as it is a player added event, also, use a character added event, as the character is loaded in after the player
it worked for me?
Reference the Character instead, use :MoveTo()