Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Repositioning a player model's body parts?

Asked by 7 years ago
Edited 7 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:

function setSize (char, value) 
    for _, child in pairs(char:GetChildren()) do
        if child:IsA("Hat") and child:FindFirstChild("Handle") then
            child = child.Handle 
        elseif child:IsA("BasePart") then
            child.Size = child.Size + Vector3.new(value, value, value)
        end
    end
end

And here's the code used to do all of the other work:

local enabled = true 

local click = Instance.new('ClickDetector')
click.Parent = giantPart

click.MouseClick:connect(function(hit)
    local char = hit.Character
    local player = game.Players:GetPlayerFromCharacter(char)
    local cenable = true
    if char and cenable then
        char.Archivable = true
        local m = char:Clone()
        if m then
            cenable = false
            local head = char:FindFirstChild("Head")
            local face = head:FindFirstChild("face")
            if enabled and head and game.Players:GetPlayerFromCharacter(char) and m then
            enabled = false
            setSize(m, 5)
            m.Parent = game.workspace
            player.Character = m
            if player.Character == m then
                game.workspace.Camera.CameraSubject = player.Character
                game.workspace.Camera.CameraType = "Custom"
            end
            wait(5)
            char.Parent = game.workspace
            char.Parent = player.Character
            player.Character = char
            char.Parent = game.workspace
            char:MoveTo(player.Character.Torso.Position)
            m:Destroy()
            if player.Character == char then
                game.workspace.Camera.CameraSubject = player.Character
                game.workspace.Camera.CameraType = "Custom"
            end
            wait(2)
            enabled = true
            cenable = true
        end
        end 
    end 
end)

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!

0
Could you upload the whole code? nicemike40 486 — 7y
1
The problem is the welds that hold your limbs together. When you change the size of the limbs, they will still remain the same distance away from each other as before. I hate welds, so I'm gonna be able to give much advice on editing them. Perci1 4988 — 7y
0
@nicemike40 Just did! DepressionSensei 315 — 7y
0
@Perci1 it all makes sense now.. thanks for the explanation! DepressionSensei 315 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

You need to add place markers that are non-CanCollide and transparent to the arms and legs positions before you move them, then after the growing has finished, just set the various parts positions to the place markers positions. then destroy all the place markers and extra model. i would add it to your code is more complicated than what im used to. Good luck though :)

0
What do you mean? DepressionSensei 315 — 7y
0
i mean add parts that are non can collide to mark the position of where the arms are originally located before you grow and shrink them, then just set the models arm and leg positions to the individual place markers positions ace12345678135 50 — 7y
0
That wouldn't work. The issue isn't with the position of the body parts, and if it was, it'd be really easy to fix. The issue is that the welds have the same position which is why the body parts are locked into place. Even if your solution did work, it'd instantly kill the player since the head would be dislocated from the joint. The proportion change distorts the position of each of the parts, I' DepressionSensei 315 — 7y
Ad

Answer this question