Problem with HumanoidRootPart Teleportation

I created a minigame script but for some reason it wouldn’t teleport the player to the game spawn. Here’s the code if you wanna test:

local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status

local function obbymap1()
	local a = game.ServerStorage.Test:Clone()
	a.Parent = game.Workspace
	wait(30)
	a:Destroy()
end

InRound.Changed:Connect(function()
	if InRound == true then
		for i, player in pairs(game.Players:GetPlayers()) do
			local gameSpawn = game.Workspace.GameSpawn
			player.Character:MoveTo(gameSpawn.Position)
		end
	end

	local ran = math.random(1, 3)
	if ran == 1 then
		obbymap1()
	elseif ran == 2 then
		print("no obby oops")
	elseif ran == 3 then
		print("no obby oops")
	end
end)

local function timer()
	while true do
		for i = 10, 1, -1 do
			InRound.Value = false
			wait(1)
			Status.Value = "Intermission: "..i.." seconds"
		end
		for i = 30, 1, -1 do
			InRound.Value = true
			wait(1)
			Status.Value = "In game: "..i.." seconds"
		end
	end
end

spawn(timer)

Any errors? The code looks fine so far

Alright, firstly, any errors at all?
Are you sure it gets to that stage? Have it print into output
make sure you do have another end after it!
(like this:)

if InRound == true then
		for i, player in pairs(game.Players:GetPlayers()) do
			local gameSpawn = game.Workspace.GameSpawn
			player.Character.HumanoidRootPart.Position = gameSpawn.Position
		end
	end
end

I would also reccomend using CFrame instead of position

Yep CFrame is the only way. Also if in character added a yield is necessary to overwrite the default spawn system.

Here is what happens when you use position

1 Like

I think

if InRound == true then
	for i, player in pairs(game.Players:GetPlayers()) do
		local gameSpawn = game.Workspace.GameSpawn
		player.Character:MoveTo(gameSpawn.Position)
	end
end

Would work here

there’s none.

I’ve tried. Still, doesn’t work.

outputted nothing… am i using the for loop wrong?

You need to use CFrames to update the Humanoid Root Part’s position. This code should work. Updating position of the whole model does weird stuff with the welds and Motor6d’s.

if InRound == true then
	for i, player in pairs(game.Players:GetPlayers()) do
		local gameSpawn = game.Workspace.GameSpawn
		player.Character.HumanoidRootPart.CFrame = gameSpawn.CFrame
	end
end