So my idea is simple but i don’t quite know how to execute this.
I basicly want the player to be able to switch between their own character and another character (not neccesarily a player character) when they press Q.
I have tried looking for solutions on the Developer Forum, but most of them are outdated.
As far as I know, you’ll need to work on both the client and the server to make this possible. First, you’ll set the player’s character as the new character.
local CurrentCharacter = Player.Character
Player.Character = newCharacter -- needs to be a model with a humanoid
If you want the animations of the current character to transfer to the new one, you’ll need to clone the script called “animate” from the current character.
local CurrentCharacter = Player.Character
Player.Character = newCharacter -- needs to be a model with a humanoid
local Animate = CurrentCharacter.Animate
Animate.Parent = Player.Character
Finally, on the client side, you’ll have to change the camera subject from the current camera to the humanoid of the new character.
local CurrentCamera = workspace.CurrentCamera
local function UpdateCamera(newCharacter)
CurrentCamera.CameraSubject = newCharacter.Humanoid
end
About the animations, to make them work in case you want to use those from the old character, you have to ensure that they have the same rigs. Otherwise, there may be issues because the animator for R6 and R15 are different.
About the character freezing, it could be an issue with the model, as during a test with an R6 dummy, I couldn’t replicate the error
I didn’t use the animation from the old character and when I was testing I was doing it with an R15 dummy instead of R6 which you used. The old character was R15 too.
I created a test code here with the R15 dummy, and it’s working correctly with the following code on the server.
local function UpdateCharacter(Player, newCharacter)
local CurrentCharacter = Player.Character
Player.Character = newCharacter
CurrentCharacter.Animate.Parent = Player.Character
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
task.wait(10)
UpdateCharacter(Player, workspace.Rig)
end)
end)
To make the animations work, you need to transfer the ‘Animate’ from your character to the other one or use another ‘Animate’ that matches the character’s rig. If the person you’re changing the character for is a player, you can simply clone their ‘Animate’, delete the current one, and add the cloned one.
About the character freezing error, could you send a video of how it happens?