SOLVED Can't get the HumanoidRootPart with a ServerScript?

I can’t seem to get the HumanoidRootPart of the Player with my Script in ServerScriptService?
Please help.

Script:

-- // Copyright 2022, UnspeakableGames112, All rights reserved.

game.Players.PlayerAdded:Connect(function(plr)
	local char = plr.Character
	local tppart = workspace.Lobby:WaitForChild("LobbySpawn")
task.wait(1)
	char.HumanoidRootPart.CFrame = tppart.CFrame
end)

Here are some pictures.
image
The Lobby.
image
And the script.


Also here is the error.

local char = plr.Character or plr.CharacterAddded:Wait()
try that

2 Likes

Oh my jeez, you people reply so quickly. I will try that.

Try this instead.

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("HumanoidRootPart").CFrame = yourPart.CFrame
end)
end)
1 Like

Change your code to this:

--//Services
local Players = game:GetService("Players")

--//Variables
local tppart = workspace.Lobby:WaitForChild("LobbySpawn")

--//Functions
Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	
	task.wait(1)
	character:PivotTo(tppart.CFrame)
end)
1 Like

Both works, thank you guys for helping me with this. Appreciate it.