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

Making welds with rotation?

Asked by
Nickoakz 231 Moderation Voter
10 years ago

I have this sphere like ball made with parts that are rotated and cframed. Is it possible to weld them all together without removing its rotation?

all=Workspace.Model:getChildren()
for a=1,#all do
    if all[a]:IsA("BasePart") and all[a].Name=="Holder" then
        holder=all[a]
    end
end
for a=1,#all do
    if all[a]:IsA("BasePart") and all[a].Name~="Holder" then
        local weld=Instance.new("Weld",all[a])
        weld.C0=all[a].CFrame--+all[a].CFrame.Angles
        weld.Part0=all[a]
        weld.C1=holder.CFrame
        weld.Part1=holder--+holder.CFrame.Angles
    end
end
for a=1,#all do
    if all[a]:IsA("BasePart") then
        all[a].Anchored=false
    end
end

Before script runs.. postimg.org/image/y90gh2b1v/ After script runs.. postimg.org/image/55c8ktmyb/

1 answer

Log in to vote
1
Answered by
hiccup111 231 Moderation Voter
10 years ago

Replace line 09-13 with this:

    local weld = Instance.new("ManualWeld",all[a])
    weld.Part0 = all[a]
    weld.Part1 = holder

    weld.C0 = weld.Part0.CFrame:inverse()
    weld.C1 = weld.Part1.CFrame:inverse()

I've only learned this recently, but ManualWelds seem to be able to weld objects that are not anchored.

If you use a normal Weld, and the parts are un-anchored, the cframes get messed up.

0
All welds do not function if any of the parts joined are anchored. They only work if both parts are un-anchored. The reason the cframes get "messed up" is because you do not use the C1 property correctly. MrNicNac 855 — 10y
0
This answer helped the issue. Thanks. Nickoakz 231 — 10y
Ad

Answer this question