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

Why doesnt my weld set properly?

Asked by
jgftr7 74
1 year ago

I am creating an equip script for a sword. My sword doesn't set its Coordinate Frame appropriately. I don't know if this is a problem with the weld or the :PivotTo() function.

Here is what I have going on:

    local PlayerArm = character:FindFirstChild("Right Arm")

    local newSword = weapons.Sword:Clone()
    newSword.Name = "Sword"
    newSword.Parent = PlayerArm

    local Handle = newSword.PrimaryPart

    local newWeld = Instance.new("WeldConstraint")

    newWeld.Name = "HandConnecter"
    newWeld.Part0 = PlayerArm
    newWeld.Part1 = Handle
    newWeld.Parent = PlayerArm

    local adjustedCFrame = PlayerArm.CFrame * CFrame.new(0,-1,0) --Lower the sword

    newSword:PivotTo(adjustedCFrame * CFrame.Angles(0,math.rad(90),math.rad(90)))

1 answer

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

My guess is that you have to create the weld after using PivotTo:(). Additionally try setting Part0 to Handle and Part1 to PlayerArm.

Ad

Answer this question