Problem with spawning character in a location

Hello. I wanna make character spawn in a spot, but the script doesn’t work and I don’t know why.

Here’s the code:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character.HumanoidRootPart.CFrame = game.Workspace.SpawnPart.CFrame
	end)
end)
1 Like

Hey!

Your original code did work for me. However, here’s my version of your code:

game.Players.PlayerAdded:Connect(function(Player)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	Character:MoveTo(game.Workspace.SpawnPart.CFrame.Position)
end)

Make sure there actually is a part named “SpawnPart” in the Workspace.

1 Like

Could you give some information about how the game is organised?
Like where is the script and are you getting any errors?

User Character:PivotTo() as character is a model, it will move the whole model to that certain cframe.

Still doesn’t work. I don’t know what’s the problem, it doesn’t give me any errors.

The game is a roguelike dungeon game. No, it doesn’t give me any errors. The script is in StarterCharacterScripts.

Make sure the script is a server script and place it in serverscriptservice.
Or you could make it local and just replace it with:

local character = script.Parent
character:WaitForChild("HumanoidRootPart.CFrame"):PivotTo(workspace:WaitForChild("SpawnPart").CFrame)

Still doesn’t work.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		character:PivotTo(game.Workspace.SpawnPart.CFrame)
	end)
end)

Thank you so much. I placed the script in wrong place.

Mark it as solution to close the thread

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.