Script is supposed to move a player to a safe area when they join the game/server, however trying to get mulitple players to join gives me this error:
"ServerScriptService.Spawn_CFrameScript:5: attempt to index field 'Character' (a nil value)"
Here's the script:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
repeat wait() until
player.Character:WaitForChild("HumanoidRootPart").CFrame ==
workspace._SpawnHub.SpawnHub.CFrame
end)
Even this configuration gives the same error too.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
wait()
player.Character:WaitForChild("HumanoidRootPart").CFrame =
workspace._SpawnHub.SpawnHub.CFrame
end)
It's probably a real easy fix but I just can't seem to get my eye on what is wrong, so I'm turning this towards the professionals. What is wrong with my script and what needs to be changed, so it works correctly?

3 comments
This should work, if it doesn't let me know so I can fix it for you.
It works perfectly! Thank you for taking time out of your day to help me.
No problem!