So, I've got this script that's supposed to teleport the player to a random spawn point if its name is in a table. However, it prints the debug but doesn't teleport the player.

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(c)
		if FoundInTable(eliminated,p.Name) then
			print('Already eliminated!') -- this prints
			local ssp = workspace:WaitForChild('SpecSpawnPoints')
			local spawnpoint = ssp:GetChildren()[math.random( 1,#ssp:GetChildren() )] -- will turn into variable later
c:WaitForChild('HumanoidRootPart').CFrame = spawnpoint.CFrame + Vector3.new(0,5,0)
			
		end
	end)
end)

I suspect that this might be a problem with HumanoidRootPart, as I'm calling it right where it gets created. Does anyone have any ideas?

1 comment

0

It was a problem with the HumanoidRootPart. I just added a wait before the teleportation line, and it worked.