Repositioning a player model's body parts?
Asked by
8 years ago Edited 8 years ago
Hi!
Today I was making a script that makes your character model grow in size before shrinking back to its base size. My issue is with the position of the body parts after the size change occurs.
To prevent the joints from breaking I've cloned the player's character and all of it's children to a model that grows in size before taking the place of your character for several seconds before switching back.
I've tested the model before making it grow in size and its body part are all perfectly positioned like a normal character model. But when the model's size has been tampered with, this happens: http://prntscr.com/cwa8c4. The player's body parts become compact, no animation occurs, and the model simply becomes a "levitating meat cube"
I've tried changing the position of the character's body parts with Vector3, but the changes don't stay, and if I attempt position the head, the player will die instantly, because the head weld will break.
Here's the function that sets the player's size:
1 | function setSize (char, value) |
2 | for _, child in pairs (char:GetChildren()) do |
3 | if child:IsA( "Hat" ) and child:FindFirstChild( "Handle" ) then |
5 | elseif child:IsA( "BasePart" ) then |
6 | child.Size = child.Size + Vector 3. new(value, value, value) |
And here's the code used to do all of the other work:
03 | local click = Instance.new( 'ClickDetector' ) |
04 | click.Parent = giantPart |
06 | click.MouseClick:connect( function (hit) |
07 | local char = hit.Character |
08 | local player = game.Players:GetPlayerFromCharacter(char) |
10 | if char and cenable then |
11 | char.Archivable = true |
12 | local m = char:Clone() |
15 | local head = char:FindFirstChild( "Head" ) |
16 | local face = head:FindFirstChild( "face" ) |
17 | if enabled and head and game.Players:GetPlayerFromCharacter(char) and m then |
20 | m.Parent = game.workspace |
22 | if player.Character = = m then |
23 | game.workspace.Camera.CameraSubject = player.Character |
24 | game.workspace.Camera.CameraType = "Custom" |
27 | char.Parent = game.workspace |
28 | char.Parent = player.Character |
29 | player.Character = char |
30 | char.Parent = game.workspace |
31 | char:MoveTo(player.Character.Torso.Position) |
33 | if player.Character = = char then |
34 | game.workspace.Camera.CameraSubject = player.Character |
35 | game.workspace.Camera.CameraType = "Custom" |
What I want to know is why this is happens, and hopefully how to fix it.
Please keep in mind that the player's character model has been replaced with a cloned model that's size has been changed to the value input.
Thanks!