My apologies if this post has the wrong category/tag since its my first and for my possibly bad scripting/script location.
I am currently trying to make a game similar to the Hyrule Warriors legends / age of calamity style of gameplay, and I’m starting with the in-game character swapping.
The issue I’m currently running into is when I set the player.character to another character/rig in the workspace and changing the Camerasubject to the model.humanoid, no input is registered for some time.
I do plan on adding some more playable characters later on but for now, I’m just sticking with the base 4 shown.
Evidence + possible solution.
This is the current script and it’s location which handles all of the UI/character changing.
Currently, the only solution I have found is simply waiting as after some time it simply works, so I’m unsure if I should try redoing the system or just put a intermission over to hide the problem.
I know that the animations don’t work which I will also have to fix, but I’ll try and sort that after I find a solution for this current problem.
If I recall correctly, primary reason it would do this insanely delayed or input eating treatment is because the client doesn’t have ownership over the other characters. Try telling the server each time you switch to a new character, leaving the server doing the handling of setting your new player.Character and swapping the new ownership over to the player who is switching.
I forgot some of what I did for my own system which made it work but yeah I’d probably try starting there if you haven’t already.
As for animations, I think the quick and easy route I used is just copy pasting a local script, parenting it to a place where local scripts can be run, such as in the player, character etc. then waiting a frame for it to register and run the script. Then preparent it to the new character. You can try this during runtime or during the moment you switch your character.
And by when you switch your character, I mean when the client and server recognize the swapped character as your new and current player.Character.
The method does seem unsightly, and a cleaner method would be creating your own module version of the animation script. Which would serve you longer allowing it to feel more custom and allowing more diverse use.
Correct me if I am wrong, what your saying is that each time I swap to a new character, I should use NetworkOwnership to swap the character from the server to the player which should hopefully fix the delayed input?
And as for the animations, I either make a local script to somewhere like StarterCharacterScripts / StarterPlayerScripts, then moving it or cloning it to the new character when the experience is running or when the client has control over the character.
Or alternatively, creating a seperate module of the animation script for more of a wider range of usage?
Update, I’ve placed a duplicate of the Animate script into replicatedStorage then, inside the CharacterSelect script, cloned and set the parent to the character I’m controlling and it seems to have worked.