Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't my teleportation script teleport all players?

Hey all, basically, the script works but it doesn't teleport all players, only one. Any ideas on why this is would be helpful. :)

for i, player in pairs(plrs) do
		if player then
			
			character = player.Character
			
			if character then
				--Teleport 
				
				local gamepad = game.Workspace.GamePad
				
				character:FindFirstChild("HumanoidRootPart").CFrame = gamepad.CFrame
				
				local GameTag = Instance.new("BoolValue")
				GameTag.Name = "GameTag"
				GameTag.Parent = player.Character
				
			else 
				--There is no character
				if not player then
					table.remove(plrs, i)
				end
			end
		end

1 comment

0

cant see a reason why it wouldn't work other than how you have character just set to player.Character, you should use "player.Character or player.CharacterAdded:Wait()"

1 answer

try doing

local AllPlayers = game.Players:GetChildren()
for plr = 1, #AllPlayers do
	local Player = AllPlayers[plr]
	local gamepad = game.Workspace.GamePad
	Player.Character:MoveTo(gamepad.CFrame)
	local GameTag = Instance.new("BoolValue")
	GameTag.Name = "GameTag"
	GameTag.Parent = Player.Character
end

this is basically a re-written version of your code, but much simpler and using different methods which should hopefully work.

This discussion is preserved as it was. New answers, comments, and votes are closed.