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

How do you weld models, or are you even able to?

Asked by
wookey12 174
7 years ago

The title, idk if it is the issue. i stuck a script so when a player joined, it would stick a helmet on their head.

local Helmet = game.Workspace.Helmet

wait(1)

local weld = Instance.new("Weld", game.Workspace)

weld.Part0 = game.Workspace.Helmet
weld.Part1 = game.Players.LocalPlayer.Character.Head

The helmet IS a model. idk if that changes anything. my output says bad cast, and brings me to line 7 when i click on it. anyone able to help?

1 answer

Log in to vote
0
Answered by 7 years ago

No, you cannot weld models themselves. You should first weld all the parts in the model together, then weld one part in the model to the character's head.

Here's a weld script I made a while back, feel free to use and manipulate it to make it work for you. Please leave an upvote if I helped! :)

local prev
local parts = script.Parent:GetChildren()
for i = 1,#parts do
    if ((parts[i].className == "Part") or (parts[i].className == "Handle") or (parts[i].className == "UnionOperation"))  then
        if (prev ~= nil) then
            local weld = Instance.new("Weld")
            weld.Part0 = prev
            weld.Part1 = parts[i]
            weld.C0 = prev.CFrame:inverse()
            weld.C1 = parts[i].CFrame:inverse()
            weld.Parent = prev
            parts[i].Anchored = false
        end
        prev = parts[i]
    end
end
for _,item in pairs(script.Parent:GetChildren()) do
    if item:IsA("UnionOperation") or item:IsA("Part") then
        item.Anchored = false
    end
end
0
You need at least 25 rep to upvote https://scriptinghelpers.org/help/user-privileges OldPalHappy 1477 — 7y
0
Also .className is deprecated https://i.gyazo.com/e0de3cb6e9cb1900ec7c60d7dd58175c.png OldPalHappy 1477 — 7y
0
This is an old script. The original asker also does have 25+ rep. joritochip 705 — 7y
Ad

Answer this question