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

How do i copy players in workspace?

for _, model in pairs(workspace:GetChildren()) do
			if model:IsA("Model") then
				for _, part in pairs(model:GetChildren()) do
					if part:IsA("Humanoid") and not plr.Character.Humanoid then 
						local copy = part.Parent:Clone()
						copy.Parent = workspace
						copy.HumanoidRootPart.CFrame = part.Parent.HumanoidRootPart.CFrame
						game.Debris:AddItem(copy, 10)

					end
				end

			end
		end
		

so here i tried to copy everything that had a humanoid in it and it doesnt work so idk what to do

2 answers

✓ Accepted answer

What Dev answered is almost correct, however it won't work since the character itself isn't archivable. Theres also a lot of unneccesary code, and ideally it can look as short as this:

for _, chars in pairs(workspace:GetChildren()) do
	if chars:FindFirstChild("Humanoid") and chars ~= plr.Character  then
		chars.Archivable = true
		local copy = chars:Clone()
		copy.Parent = workspace
		game.Debris:AddItem(copy, 10)
	end
end
  • All you have to do is check if theres an instance with a humanoid, and it isn't the plr's char
  • You have to make their character archivable before you copy it, otherwise you get an error
  • The copy will already have the same position as the instance it copies

1 comment

0
  • Also you might not even have to set the parent again, not sure if the clone still keeps the original's parent.
for _, model in pairs(workspace:GetChildren()) do
	if model:IsA("Model") then
		for _, part in pairs(model:GetChildren()) do
			if part:IsA("Humanoid") and not plr.Character.Humanoid then 
				local copy = part.Parent:Clone()
				
				copy.Archivable = true -- Archivable is turned off for all Player's Characters, you have to Enable it if you want to make a copy of a Character
				
				copy.Parent = workspace
				copy.HumanoidRootPart.CFrame = part.Parent.HumanoidRootPart.CFrame
				game.Debris:AddItem(copy, 10)

			end
		end

	end
end

hope this helps

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