Make player control a secondary character

Hi everyone, i’m currently planning to make a game similar to Pocket Tanks or Worms.

I’m trying to let the player swap between 2 characters that are present at the same time during the match.

Notice i don’t need to swap the player aspect, it’s not a morph.

I’ve searched for like 2-3 hours for a solution, also asked chatGPT for support without succes,
the best result i got is by using 2 scripts.

A LocalScript

local player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Q TO SWITCH
UserInputService.InputBegan:Connect(function(input, isProcessed)
	if not isProcessed and input.KeyCode == Enum.KeyCode.Q then
		print("Switching character")
		ReplicatedStorage.EndTurn:FireServer()
	end
end)

And a ServerScript

Char = workspace.Player1

game.ReplicatedStorage.EndTurn.OnServerEvent:Connect(function(Player)
		
	print(Player.Parent,Player)	
	Player.Character = Char
	
end)

Doing all of this in a LocalScript makes the player unmovable, resulting useless.

The biggest problem for now is that:

  • After Swap the player has no animation. (all characters are a clone of my original placed in the Workspace)
  • After Swap the previous character gets deleted.

I’ve come to the conclusion that I have two available options:

  1. Do not swap at all, clone the player and place it on the same position → place the player on the position of the next character → play → repeat for all switches
  • I plan to adding idle animations where characters may talk, dance or something else, erasing them and replacing them could break the animation if is on going.

  1. Swap the player but clone the previous character to be able to switch to it again.
  • Animations still wouldn’t work, maybe i could clone the LocalScript of the Animations inside them but idk if that could work.

Is there any other way to achieve this? i don’t need a full script or nothing but i’m not an expert so a good explanation of how it could work would be great.

1 Like

you could replace the features of the character with another one (clone parts and accessories)

or you could make a custom character controller which would be really easy to switch with

1 Like