Cloning every player!

So I’m trying to clone the player it worked but I want it to happend every second to every single player so every second everybody clones this is my script rigth now does anyone have an idea how I can do that?

wait(10)
while true do
	local playerToClone = "My UserName"

	function CloneMe(char) --a function that clones a player
		char.Archivable = true
		local clone = char:Clone()
		clone.Name = "Clone"..playerToClone
		char.Archivable = false
		return clone
	end

	local charClone = CloneMe(game.Players[playerToClone].Character) --connects function and defines "charClone" as the result of the function
	charClone.Parent = game.Workspace
	
	game.Players[playerToClone].leaderstats.Clones.Value += 1
	wait(1)
end

It seems like this script will work for one player as defined by playerToClone is that correct? does it not clone them every second? Can you explain in more detail what you are expecting this script to do and what it is really doing?

so this script will only clone me cause its seraching me in the players but I want this to happend to all the players in the server

Cant you just do this?

for i, v in pairs(game.Players:GetPlayers()) do
	v.Character:Clone()
	v.Parent = workspace
end

Ok then we can extend this to all players with the Players service like so.

local Players = game:GetService("Players")

function CloneMe(char) --a function that clones a player
	char.Archivable = true
	local clone = char:Clone()
	clone.Name = "Clone"..char.Name
	char.Archivable = false
	return clone
end

task.wait(10)
while true do
	-- looping for each player in the game
	for _, player in Players:GetPlayers() do
		
		-- a player may not have a character (if dead or logging in)
		if player.Character then
			
			-- the same clone function
			local charClone = CloneMe(player.Character) --connects function and defines "charClone" as the result of the function
			charClone.Parent = game.Workspace

			player.leaderstats.Clones.Value += 1
		end
	end
	
	-- wait for 1 second after the for loop
	task.wait(1)
end

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