I am trying to allow a single player to click on another player, then clone the character of the player they clicked on, and give the clicking player control of one of the clones.

Here's some of the code I have tried:

--run on the server, recieves the player that is clicked on as the only argument in the tuple
workspace.SwapChars.OnServerEvent:connect(function(player,...)
	local tuple = {...}
	--make the character clonable
	tuple[1].Character.Archivable = true
	player.Character = tuple[1].Character
	tuple[1].Character = tuple[1].Character:Clone()
	--move the player who was clicked on to the lobby
	tuple[1].Character:MoveTo(workspace.LobbySpawn.Position + Vector3.new(0,2,0))
end)

Instead of working as expected, this causes one player to respawn and the other to disappear permanently.

Does anyone know how to do this?

4 comments

1

I would just change the camera to focus on the clone and add in a movement script. If I'm understanding what you're trying to do, it should work. If not, sorry for the misunderstanding.

0

Why use VarArgs(...) when you could just use regular arguments?

0

The clones don't show up at all, so I can't change the camera to follow it. If I don't call the Clone() function, the player takes over the character just fine. When I clone the character, it seems to destroy both.

0

I could use regular arguments, this is just the way I learned to do it. Thanks for the tip. @antonio