Team Teleport Not Functioning

Been trying to get this teleportation script to work for a while now. I put it behind to finish my other scripts for a game. Now that I’m getting back to it, I don’t understand why the script isn’t teleporting the players in the team.

Here is my script:

local teleportationTarget = CFrame.new(-170.3, 6.2, 207.8);
if game.Teams:FindFirstChild("Spectators") and #teams.Spectators:GetPlayers() > 0 then
			print("DID IT WORK?");
			for i, players in ipairs(game.Teams.Spectators:GetChildren()) do
				if players.Character and players.Character:FindFirstChild("HumanoidRootPart") then -- Make sure the player's character and HumanoidRootParts exist
					players.Character.HumanoidRootPart.CFrame = teleportationTarget + Vector3.new(0, 5, 0);
					wait(1);
				end	
			end
			print("NOPE?");
		end

It goes through those lines of code just fine. “DID IT WORK?” and “NOPE?” printed out just fine.

instead of using :GetChildren(), use :GetPlayers().

2 Likes

That did it. Can you explain to me the difference between the two and how they work in relation to game.Teams?

1 Like

Alright, :GetChildren() would get the children of the Team inside of game.Teams.Spectators (which would lead to nothing if you had nothing inside of it/under it) while the :GetPlayers() would get the players that are in the team.

2 Likes

Thank you so much! :slight_smile: