Teleportation Error

For some reason this script teleports the players but not the seeker?

I have a Folder inside the map named SeekerSpawns which is where I want the seeker to spawn.

image

TeleportPlayers Function:

local function TeleportPlayers(AvailablePlayers, Spawns)
	for _, Player in pairs(AvailablePlayers) do
		if Player.Character then
			if Player.Character:FindFirstChild("HumanoidRootPart") then
				Player.Character.HumanoidRootPart.CFrame = Spawns[math.random(1, #Spawns)].CFrame + Vector3.new(0, 5, 0)
			end
		end
	end
end

When I teleport the seeker:

TeleportPlayers({Seeker}, Map.SeekerSpawn:GetChildren())
1 Like

You forgot to add ‘s’ to Map.SeekerSpawns

1 Like

LOL! OMG my guy, I stuffed up beyond imagination!

Also, since Player is a part of the AvailablePlayers table, and not of game.Players:GetChildren(), you cant get their character like that, you’ll need to find their character in workspace

Replace it with this :

local function TeleportPlayers(AvailablePlayers, Spawns)
	for _, Player in pairs(AvailablePlayers) do
        --if we found the character of that Seeker, in workspace - then
		if game.Workspace:FindFirstChild(Player) then
			if game.Workspace:FindFirstChild(Player):FindFirstChild("HumanoidRootPart") then
				game.Workspace:FindFirstChild(Player).HumanoidRootPart.CFrame = Spawns[math.random(1, #Spawns)].CFrame + Vector3.new(0, 5, 0)
			end
		end
	end
end



--Calling the function--
TeleportPlayers({"NameHere"}, Map.SeekerSpawns:GetChildren())

This should work perfectly.

As long as AvailablePlayers is an array of player instances indexing their “Character” property is fine.