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

Why are some of my backpacks being welded differently than others?

Asked by 6 years ago

I need some help understanding why my weld script is acting a bit odd. I've created 9 backpacks for my upcoming game. In each backpack is an invisible part named WeldPart. I duplicate the exact same part into each backpack and build the pack around it as a model. Out of the 9 packs, 7 weld exactly as they should. Pack #6, however, welds to the bottom of the model instead of the front, and pack #9 welds to the side. Here are pictures showing what I mean...

images

All backpacks are welded to the player character through this script...

function weldToHuman(a,b) -- put person.torso as a and put object as b
    b.CFrame =a.CFrame * CFrame.new(0,0,1.5) 
    local  weld = Instance.new("Weld")
    weld.Part0 = a;
    weld.C0 = a.CFrame:inverse()
    weld.Part1 = b;
    weld.C1 = b.CFrame:inverse()
    weld.Parent = a;    
    return weld;
end
game.Players.PlayerAdded:connect(function(player)
    print(player.Name .. " Welcome");
    player.CharacterAdded:connect(function(character)
        print(character.Name .. "  character")
        wait(6);-- waiting until character loads as  you become a player before a character
        local conName = player.container:WaitForChild("ConName")            
        local pTorso = character:FindFirstChild("UpperTorso") or character:FindFirstChild("Torso")
        print(conName.Value)
        local pcontainer = game:GetService("ServerStorage"):FindFirstChild(conName.Value):Clone()
        pcontainer.Parent = character
        pcontainer.Name = "Container"
        local weldcontainer = pcontainer:FindFirstChild("WeldPart")
        weldToHuman(pTorso,weldcontainer)
    end)
end)

0
It will all depend upon the rotation of the welded parts. A lot of builders do not work in the same axis so up it not up for all parts. User#5423 17 — 6y
0
An accessory or weld constraint would be easier to use in this case. User#5423 17 — 6y
0
After looking through the accessory page in the API, that does look much easier for this. I'll give it a try. Thanks!    EDIT: Just gave it a try on pack #9, worked great.  I can't thank you enough, you saved me several more hours of headache! Buggims 4 — 6y

Answer this question