Topic: I wanted to create an item that could work just like the BodySwap potion, but instead of just switching the positions and HumanoidDescriptions of 2 players it would allow you to fully trade bodies with anybody, including NPCs! I want to create such item because i want you to be able to switch with zombies in my game, you start controlling the zombie, retaining all of its health, speed, jumppower and even missing limbs, while the zombie starts controlling your body with the same things applied to him.
The issue: It never really works, swapping children of two alive and active characters seems to break stuff, when i tried that on a simulated server after using the body swap potion it seemed like only my camera got transported into the second character, the second character has also lost all of his accessories and i could only control my original character (i also couldn’t jump for some reason).
Solutions i have tried: swapping only the humanoids, swapping everything BUT humanoids, swapping one child a second, only swapping the body parts - all give slightly different results, but all can be described in two words - ABSOLUTE FAILIURE.
Yeah, that’s about what i wanted to say, i apologize if you see any gramatical erorrs, it’s because English is not my native language.
I see what you are trying to do, but I think swapping stuff like humanoids and controls would break many things like core scripts. Instead, I think you should just apply the character’s features to each other. Think of it like the body swap potion, but it swaps more than humanoid descriptions and positions.
What I mean by that is first, you could start with swapping the humanoid descriptions and position, then you can swap the humanoid properties, like health, speed, jumppower, etc. Then, for the missing limbs, just check what limbs are missing and delete them on the swapped character.
This will make it so you don’t actually “swap” characters, but it still has the same effect, making it so you don’t need to deal with all the possible problems of truly swapping characters.
The only hard part I see with this method, is adding limbs if they are deleted. I think the safest way to do this would be to just reload the character, but that takes a bit of time, so there may be better ways.
I hope this helps, and if I wasn’t clear enough, or you need any more help, tell me and I try to help!
Nevermind, i fixed it myself. I basically made the two characters trade scripts, so that the NPCs can retain their AI, then i set the player’s (or both player’s) characters to nil. This deletes the old characters, yeah, but “deleting” is just a fancy word for setting something’s parent to nil, so i just set the characters’ parent to workspace before they could be truly gone and then swapped the players’ characters. Simple. I set all of the Body Parts inside both the characters’ Network Owner to either player (if the character is player-driven), or to server (if the character is an NPC). The hardest part was to fix the camera afterwards, but then i just added a local script in StarterPlayerScripts that would look out for any character changes and then fix the camera.