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

How to fix weld not going to the correct position and having correct rotation?

Asked by 1 year ago
Edited 1 year ago

I have been trying to make a sword attach to the back when unequipped, but I cannot get the position and orientation correct. I have tried multiple times and tried multiple different solutions and cannot seem to find an answer. I thought that getting the position of the characters torso and the position of the primarypart of the model and then subtracting the model's position from the torso's position would work, but it makes the model be in a spot it shouldn't. I have also tried centering the player at 0,3,0 and trying that way, but that also did not work. I also have to test the sword position in game due to the custom idle animation moving the torso.

This is my code:

unequipped.OnServerEvent:Connect(function(player, name)
    local character = player.Character
    folder = character.Weapons
    local weapon = game.ReplicatedStorage.Weapons:FindFirstChild(name)
    model = weapon:Clone()
    model.Parent = folder

    local weld = Instance.new('Weld')
    weld.Parent = model.PrimaryPart
    weld.Part0 = model.PrimaryPart
    weld.C0 = CFrame.Angles(-46.38, 72.75, 179.9) * CFrame.new(1.9, 5.5, 1.3)
    weld.Part1 = character.Torso
end)

Any help would be very appreciated, I have been trying for ages and my friend cannot do the unsheathe animation until the weld position is fixed.

1 answer

Log in to vote
0
Answered by 1 year ago

I went in game, anchored the model, moved it into position, and then used a weld plugin to correctly weld it. After that I used the console to print the C0 and C1 values of the weld. Now it works.

Ad

Answer this question