When I test my manual charactering script, it changes their character, but leaves their old one. But when I try destroying their old character, their leftover one is the parameter for the player.CharacterAdded function. But then using player.Character messed a few things up the last time I tested, so I have no idea what to do. Thanks for any responses.
Could you provide the script for it?
local charged = game.ServerStorage.Characters["Charged Creeper"]:Clone()
charged.Name = player.Name
player.Character = charged
charged.Parent = workspace
wait()
char:Destroy()
Edit: I spawn in the character to a spawn afterwards. Also, I have a character in StarterPlayer already, so I just put a randomizer to it to make it rarer
Have you tried removing your character before loading another one?
no, but how would I do that? Would I have to disable or destroy something when they die then put the charged creeper character on them when they respawn?
You can use Player:RemoveCharacter()
for this. When the player dies, their character isn’t removed, so the function can help for situations like this.
I would do some changes like :
1-using replicated storage.
2-using SetPrimaryPartCFrame and GetPrimaryPartCFrame to get the Cframe from the old model and setting it to the new model
3- idk how char is defined in that script but u can do:
local outdated=player.Character
then clone and set the new player.Character and destroy outdated (again idk if char is defines like that or not this is just for good measures…)
This is how I normally change my characters, try it
local classNames = {"Accessory", "Shirt", "Pants", "ShirtGraphic", "BodyColors"}
function SetPlayerCharacter(Player , Character)
for i, descendant in pairs(Player.Character:GetDescendants()) do
if table.find(classNames, descendant.ClassName) or descendant:IsA("Decal") and descendant.Parent.Name == "Head" then
descendant:Destroy()
end
end
for i, descendant in pairs(Character:GetDescendants()) do
if table.find(classNames, descendant.ClassName) then
if descendant.ClassName == classNames[1] then
local Clone = descendant:Clone()
Clone.Handle:FindFirstChildWhichIsA("Weld").Part1 = Player.Character[tostring(descendant.Handle:FindFirstChildWhichIsA("Weld").Part1)] or Player.Character["Right Leg"][tostring(descendant.Handle:FindFirstChildWhichIsA("Weld").Part1)] or Player.Character["Left Leg"][tostring(descendant.Handle:FindFirstChildWhichIsA("Weld").Part1)]
Clone.Parent = Player.Character
else
descendant:Clone().Parent = Player.Character
end
elseif descendant:IsA("Decal") and descendant.Parent.Name == "Head" then
descendant:Clone().Parent = Player.Character.Head
end
end
end
you will need to change some lines though and you can add arms/legs to the table if you want it to be replaced aswell…(sorry for the late reply btw)
Alright so what I probably want is to not respawn the player after they die in this case. This character has a rarity to it, so I can’t just put it in StarterPlayer. Also, char is defined in the player.CharacterAdded() function
did my script work??? it doesnt respawn the play and works perfectly for me…
uh it isn’t a player character thing it’s a character I made, so it doesn’t have shirts or accessories
so it wont place them, it will remove what the character has on and never replace them since your character doesn’t have them
Well, maybe you can set Players.RespawnTime
to math.huge
and make a custom respawn script for normal players.
well that might cause more issues since what if a respawn script I find bugs occasionally and breaks the game? Idk when that’d ever happen