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

Why does this weld script break the player's movement animations?

Asked by 5 years ago

I am trying to give the player a slight blue glow by cloning its body parts, making them slightly bigger than the original, and welding it to the original. This is the function that does this:

function placePart(char, v)
    char.Archivable = true
    v.Anchored = true
    local part = v:Clone()
    part.Parent = char
    part.BrickColor = BrickColor.new("Toothpaste")
    part.Material = "Neon"
    part.Transparency = .94
    part.CanCollide = false
    part.Size = part.Size + Vector3.new(0.1,0.1,0.1)
    part.CFrame = v.CFrame
    part.Name = "WeldedPart"
    weld(part, v)
    part.Anchored = false
    bodyParts[#bodyParts + 1] = part
    wait()
    v.Anchored= false
end

I call that function here:

local char = player.Character
        local rootPart = char.HumanoidRootPart
        local rh = char.RightHand
        local fold = char:WaitForChild("Attack Storage")
        local assets = rep.Assets.Lightning

        for _,v in pairs(char:GetChildren()) do 
            if (v:IsA("MeshPart") or v:IsA("Part")) and v.Name ~= "Head" then
                coroutine.wrap(placePart)(char, v)
            elseif v.Name == "Head" then
                local mesh = assets.HeadMesh:Clone()
            --  v.Anchored = true
                mesh.Name = "WeldedPart"
                mesh.CFrame = char.Head.CFrame
                mesh.Parent = char
                weld(v, mesh)
                bodyParts[#bodyParts + 1] = mesh
                v.Anchored = false
            end
        end     

Please note that not all code I wrote is included. I know for a fact the other code did not cause this problem.

0
I have fixed the problem by simply clearing the children of the cloned part. iGlaciem 72 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I have fixed the problem by simply clearing the children of the cloned part.

function placePart(char, v)
    local part = v:Clone()
    part:ClearAllChildren()
    part.Parent = char
    part.BrickColor = BrickColor.new("Toothpaste")
    part.Material = "Neon"
    part.Transparency = .94
    part.CanCollide = false
    part.Size = part.Size + Vector3.new(0.1,0.1,0.1)
    part.CFrame = v.CFrame
    part.Name = "WeldedPart"
    weld(part, v)
    bodyParts[#bodyParts + 1] = part
end
Ad

Answer this question