Control a CustomCharacter and Control his last body after?

So i want to make a script when u can control an another character and be able to return to his first body after .

Here my local script :

local UIS = game:GetService(“UserInputService”)
local camera = workspace.Camera
local chararcter = game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
local titan = workspace.DataKenny
game.ReplicatedStorage.Shifter:FireServer(“On”)
camera.CameraSubject = titan
end
end)

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.R then
game.ReplicatedStorage.Shifter:FireServer(“Off”)
camera.CameraSubject = workspace.CloneShifter:FindFirstChild(Player.Name)
workspace.CloneShifter:FindFirstChild(Player.Name).Humanoid.NameDisplayDistance = 0
end
end)

And here my Server

l> ocal ClonedPlayer

game.ReplicatedStorage.Shifter.OnServerEvent:Connect(function(player,State)
if State == “On” then
local titan = workspace.DataKenny
player.Character.Archivable = true
local ClonePlayer = player.Character:Clone()
player.Character.Archivable = false

player.Character = titan
ClonePlayer.Parent = workspace.CloneShifter

elseif State == “Off” then
local ClonedPlayer = workspace.CloneShifter:WaitForChild(player.Name)
player.Character = ClonedPlayer
ClonedPlayer.Archivable = false
player.Character.Parent = workspace
end
end)

Its working but i got some problem like when u return to your last body u can see ur name and its weird its not like when u spawn :c

2 Likes

Could you describe the problem more? Is the character feeling laggy?

Make sure the characters player controls are network owned by the player.
You need to call :SetNetworkOwner(PlayerWhoControls) on any basepart in characters.
https://developer.roblox.com/en-us/api-reference/function/BasePart/SetNetworkOwner

https://developer.roblox.com/en-us/articles/Network-Ownership

It’s cool what you’re doing, but maybe https://developer.roblox.com/en-us/articles/humanoiddescription-system would make changing bodies easier. Edit: You can revert a player back to their original character with HumanoidDescription at the end. With this, you might not even have to take control of another character using all that script. Just change the appearance to another character and change it back.