How to make sure a character lives while morphing
For my Bleach RPG, characters will morph into a built model upon spawning. Some of these models include having largely sized limbs and Torso's. Since I'm resizing the limbs to morph the character, each Motor in the Torso will temporarily have a Part1 of nil. In order to counter this, I first anchor the limb and then store the value of Part1 as an ObjectValue and then after it's finished resizing it will set the Part1 back to it's correct value.
My problem is, there are many cases in which the player will spawn and instantly die; probably since it cannot reconnect the limbs together quickly enough. It works fine it Play Solo, but the character only lives 2 out of 3 times in server mode.
Extra information: The welds C0 and C1 aren't defined in the morph script; there's a localscript (animation) that will be pasted into the character that sets the C0 and C1 if the Morph-To body is different from the typical Roblox body.
05 | for _,v in pairs (char:GetChildren()) do |
06 | if v:IsA( "BasePart" ) then |
10 | for _,v in pairs (char:GetChildren()) do |
11 | for _,x in pairs (v:GetChildren()) do |
12 | if x:IsA( "Motor6D" ) then |
13 | Instance.new( "ObjectValue" ,x).Value = x.Part 1 |
23 | for _,v in pairs (model:GetChildren()) do |
24 | local part = char:findFirstChild(v.Name) |
27 | if v:IsA( "BasePart" ) and part then |
32 | part.TopSurface = "Smooth" |
33 | part.BottomSurface = "Smooth" |
38 | elseif v:IsA( "LocalScript" ) and char:findFirstChild( "DefaultAnimation" ) then |
41 | char.DefaultAnimation:Destroy() |
42 | v:clone().Parent = char |
45 | for _,o in pairs (char:GetChildren()) do |
46 | if o:IsA( "BasePart" ) then |
47 | for _,v in pairs (o:GetChildren()) do |
48 | if (v:IsA( "Weld" ) or v:IsA( "Motor" ) or v:IsA( "Motor6D" )) and v:findFirstChild( "Value" ) then |
49 | local part 1 = v.Value.Value |
51 | v.Part 1. Anchored = false |
52 | v.Part 0. Anchored = false |