I want to ask how to make a character-switching system. I am currently making a fighting game and I want to change the script running on the player when the character is switched, I have tried to find some tutorials on YT but all are just teaching how to change the appearance but things that I want is to change the script because the different character has a different system.
Put the characters model in replicated storage where they would all have their own scripts inside of them. Then whenever you switch character change the players character to the specific character in replicated storage.
you mean I need to make a script inside the character, and when I get the character from replicated storage, the character can auto change to the player appearance?
local Players = game:GetService("Players")
local SetCharacterRemoteEvent = game.ReplicatedStorage.CharacterSkillEvent.SetCharacterRemoteEvent
SetCharacterRemoteEvent.OnServerEvent:Connect(function(plr, char)
local Character = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = Character.Humanoid
local oldCharacter = plr.Character
local newCharacter = char:Clone()
local description = Players:GetHumanoidDescriptionFromUserId(plr.UserId)
newCharacter.Humanoid:ApplyDescription(description)
plr.Character = newCharacter
newCharacter.Parent = game.Workspace
newCharacter:SetPrimaryPartCFrame(oldCharacter:GetPivot())
oldCharacter:Destroy()
end)
This is my script, I fired it from the client side and received it on the server, but why did this error code happen? Humanoid::ApplyDescription() DataModel was not available - Server - SetCharacterServerScript:14
I’m not the best scripter myself, so I not sure about that error. What I would recommend that you script is that there is an event inside replicated storage calle changeCharacter and then another script inside somewhere else (depends on where you want to call the change from). This script would fire the event and would be scripted so that the character would replace the current character.