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

Player Resize Killing instead of resizing fix?

Asked by 7 years ago

So I was making a script so I could resize players down to a certain height, just a note I am using R6 and not R15.

So here is my code

local beam = script.Parent.Beam
script.Parent.BrickColor = BrickColor.new("Really red")
beam.Transparency = 1
beam.Color = Color3.fromHSV(0, 255, 255)

local cd = script.Parent.CD
local beam = script.Parent.Beam
local debounce = false
local size = 1

cd.MouseClick:connect(function()
    if debounce == false then       
        beam.Transparency = 0.4

        beam.Touched:connect(function(hit)
            local humanoid = hit.Parent:FindFirstChild("Humanoid")
            if humanoid then
                for i,v in pairs(hit.Parent:GetChildren()) do
                    if v:IsA("Part") then
                        v.Size = Vector3.new(size, size, size)
                    end
                end
            end
        end)
    end
end)

im not sure why it kills players.

1 answer

Log in to vote
3
Answered by 7 years ago

This is killing players because you're not re-making the joints. An easy way to implement this is to make a table of the player's joints before you scale them down.

For example (Just for storing joints, not direct answer).

function storeJoints(chr)
    local joints = {}
    for i,v in pairs(chr.Torso:GetChildren()) do
        if v:IsA("Motor6D") then
            table.insert(joints,v)
        end
    end
    table.insert(joints, chr.HumanoidRootPart.RootJoint)

    return joints
end

local backupJoints = storeJoints(chr)

Later, once you've scaled down the players you want to go through this table and restore the joints. Although, you may want to scale down the joints. This should help give you an idea of what you need to do.

To answer your question directly though, it's simply because you're not restoring the joints.

Ad

Answer this question