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

Whats an Good Brick Weld Script for Cars?

Asked by 9 years ago

Okay, I have this Car Where all the bricks fall off the front.. I used this Persons Weld scripts but it does not seem to Keep the bricks welded on. I have the script in the Brick Itself. Any Ideas?

function weld()
    local parts,last = {}
    local function scan(parent)
        for _,v in pairs(parent:GetChildren()) do
            if (v:IsA("BasePart")) then
                if (last) then
                    local w = Instance.new("Weld")
                    w.Name = ("%s_Weld"):format(v.Name)
                    w.Part0,w.Part1 = last,v
                    w.C0 = last.CFrame:inverse()
                    w.C1 = v.CFrame:inverse()
                    w.Parent = last
                end
                last = v
                table.insert(parts,v)
            end
            scan(v)
        end
    end
    scan(script.Parent)
    for _,v in pairs(parts) do
        v.Anchored = false
    end
end

weld()
script:Remove()

1 answer

Log in to vote
0
Answered by 9 years ago

This is really long...

t = script.Parent
wait(5)

function stick(x, y)
    weld = Instance.new("Weld") 
    weld.Part0 = x
    weld.Part1 = y
    local HitPos = x.Position
    local CJ = CFrame.new(HitPos) 
    local C0 = x.CFrame:inverse() *CJ 
    local C1 = y.CFrame:inverse() * CJ 
    weld.C0 = C0 
    weld.C1 = C1 
    weld.Parent = x
end

function Weldnow()
    c = t:children()
    for n = 1, #c do
        if (c[n].className == "Part") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end
        end
    end
    end
    if (c[n].className == "Flag") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end

                    if (c[n].className == "Handle") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end

    if (c[n].className == "Hat") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end
        end
        if (c[n].className == "Seat") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end
        end
        if (c[n].className == "SpawnLocation") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end
        end
        if (c[n].className == "TrussPart") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end
        end
        if (c[n].className == "VehicleSeat") then
            if (c[n].Name ~= "MainPart") then
                stick(c[n], t.MainPart)
                wait()
                c[n].Anchored = false
            end
        end
    end
end

wait()

t.MainPart.Anchored = false

Weldnow()
0
Used That... Free Model :/ MicrobeBlox 5 — 9y
0
Lol, who's really gunna type that whole thing? EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question