Still have questions? Join our Discord server and get real time help.
Log in to vote

Why do my welds only sometimes work properly?

Asked by 2 years ago

Hello, so I'm welding a model to a character and having difficulty. The model I weld either works perfectly or sometimes, inexplicably, will just fail to weld properly. It will appear for half a second and then, unanchored, will fall through the world and destroy itself as if the weld is non existant.

After some testing I've narrowed it down to this; the weld is just not appearing in the model properly SOMETIMES and other times it works fine.

I've used 'repeat wait until() weld exists in the right place' to try and fix this but then it just waits infinitely. This is the script I use, I really hope someone can point out what I'm doing wrong to try and get this working 100% of the time.

local Event = game.ReplicatedStorage.AccessoryEvents:WaitForChild('HeadAccessory')
local function OnEventFired(player, detail)
    if detail == 'accessoryA' then
        local Accessory = game.ReplicatedStorage.Accessories.Head.Hat:Clone()
        local g = Accessory:Clone()
        g.Parent = player.Character
        local C = g:GetChildren()
        for i=1, #C do
            if C[i]:IsA("BasePart") then
                local W ="Weld")
                W.Part0 = g.Middle
                W.Part1 = C[i]
                local CJ =
                local C0 = g.Middle.CFrame:inverse()*CJ
                local C1 = C[i].CFrame:inverse()*CJ
                W.C0 = C0
                W.C1 = C1
                W.Parent = g.Middle
            local Y ="Weld")
            Y.Part0 = player.Character.Head
            Y.Part1 = g.Middle
            Y.C0 =, 0, 0)
            Y.Parent = Y.Part0
            C[i].CanCollide = false
            C[i].Anchored = false

I wonder if there is some property of welds I'm missing that means they can't fix properly while the character is moving sometimes or what, it breaks usually after the character has moved for the first time and is then standing still.

confusing script for me, can't help greatneil80 2311 — 2y
Okay? Samstergizmo 28 — 2y

1 answer

Log in to vote
Answered by
Nonaz_jr 439 Moderation Voter
2 years ago

the weld between middle and head is made many times in the loop, I don't see how thats what you would want to do. also you clone twice. I dont see whats wrong though, does it still happen when you comment out the line Y.C0 = CF... ?

I'm guessing g.middle is a basepart and then in the loop you create a weld between middle and middle (itself). It shouldn't be a problem but I don't know what happens when you start setting C0 and C1.

btw why not weld the whole hat beforehand to the middle part, so you can take out the loop and only need to make 1 more weld and set one C0? in any case I would first try moving g.Parent = player.Character to the end (after anchored) to see if the problem persists

more unwanted advice: in general consider making a check when a client sends an event to your server (instead of just giving them some item)

Yes sorry, this is an old script and should probably write it from scratch now but it wasn't causing any issues until now. Thanks for the advice I'll keep testing Samstergizmo 28 — 2y
also I did notice I cloned twice haha, thanks for pointing that out Samstergizmo 28 — 2y

Answer this question