All players not being teleported

Hey there I want it so as soon as the players join they get teleported to a part. however only 1 player gets teleported and the others dont. I urgently need to fix this. thanks.

game.Players.PlayerAdded:Connect(function(plr)
	
	for i, players in pairs(game.Players:GetChildren()) do
		plr.CharacterAdded:Connect(function()
			if respawned == false then
				players.Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.SpawnPart.CFrame
				respawned = true
			end

		end)

	end
	regularsound:Play()
	plr.CharacterAdded:Connect(function(character)

		
		character:WaitForChild("Humanoid").BreakJointsOnDeath = false
	end)
3 Likes

Why are you using a for loop to get the players character if you already got the player in your function?

I tried it with the player in my function but it only teleports the first player not anyone else.

No? Just do it like this

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(character)
		character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.SpawnPart.CFrame
		regularsound:Play()
	end)
end)

You want every time a player joins, for all players to be transported to the brick together? Meaning as a player in the game every time someone joins you get reset to a position? If this isn’t what you want please explain better because I’m having trouble following what you’re trying to do

yes this is practically what I want.

Is this a server or local script

its a server script i tried it again but its refusing to work.

game.Players.PlayerAdded:Connect(function(plr)

plr.CharacterAdded:Connect(function()
	for i, player in pairs(game.Players:GetPlayers()) do
			local PlrsCharacter = player:FindFirstChild("Character")
			
			if PlrsCharacter then
				
			player.Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.SpawnPart.CFrame	
			
			end

	end
	
end)

end)

1 Like

^ Not sure what the respawned value is for but try this

1 Like

This will make every player that join the server teleport to the part which is a type part. Lemme know if you need anything else.

local Players = game:GetService("Players")
local Part -- assign to part

Players.PlayerAdded:Connect(function(plr)
	-- waits for character to load ingame
	plr.CharacterAdded:Wait()
	local character = plr.Character
	character:SetPrimaryPartCFrame(Part.CFrame)
end)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.