Still have questions? Join our Discord server and get real time help.

Log in to vote

0
**Problem**:Script does not rotate the part that is being welded to the character, it appears there, but it's inside the arm, i want to rotate it so that the it faces the front and leans forward

**Script**
**vvv**

function Attach2( weapon ) print('Starting') local SelectedArmor = weapon:GetChildren() for i, v in ipairs(SelectedArmor) do print(v) if v.Name == 'Handle' then -- local animation = Instance.new("Animation") -- animation.AnimationId = 'http://www.roblox.com/asset/?id=476343798' -- local animTrack = Character:WaitForChild('Humanoid'):LoadAnimation(animation) -- animTrack:Play() --Weld-- local w = Instance.new("Weld") w.Part0 = v w.Part1 = Character:WaitForChild('Left Arm') w.Parent = Character:WaitForChild('Left Arm') v.Parent = Character:WaitForChild('Left Arm') w.C0 = CFrame.new(-1, 0.5, 0)*CFrame.new(0, -121, 0) end wait() end

Log in to vote

3
Unfortunately I don't quite understand the specifics of the problem, but one thing I can see is that you're missing one of the key rules of welds :P

The rule of thumb is that welds satisfy this equality:

part0.CFrame * c0 = part1.CFrame * c1

This might make you think that you can easily solve for c0 or c1 by dividing both sides by either part0.CFrame or part1.CFrame. The problem is that this isn't normal algebra, it's linear algebra and matrices don't have a division operation.

As a result we instead have to use the inverse instead. In linear algebra this matrix has the unique property of multiplying against the original matrix and returning the identity matrix. Now the important thing to keep in mind is that matrix multiplication is not commutative meaning A * B != B * A. Luckily for us pre-multiplying and post-multiplying by the inverse returns the same result A^-1 * A = A *A^-1 = I.

I probably confused you pretty bad so in summary all I'm saying is that:

- Exceptions may apply due to float math errors but this would hold true given a perfect calculation.

local A = someCFrame; print((A * A:inverse() == A:inverse() * A) == CFrame.new());

Anyway moral of the story here is that when using the inverse to solve for c0 or c1 the order matters. If I pre-multiply on one side I have to pre-multiply on the other and vice versa.

Eg. I can't post-multiply to solve this:

part0.CFrame * c0 = part1.CFrame * c1 part0.CFrame * c0 * part0.CFrame:inverse() = part1.CFrame * c1 * part0.CFrame:inverse()

b/c idk what c0 is and therefore can't multiply it against part0.CFrame:inverse() or part0.CFrame. In other words I've added some variables and by no means made it easier for me to solve this.

If on the other hand I pre-multiply I'm able to single out either c0 or c1

part0.CFrame * c0 = part1.CFrame * c1 part0.CFrame:inverse() * part0.CFrame * c0 = part0.CFrame:inverse() * part1.CFrame * c1 CFrame.new() * c0 = part0.CFrame:inverse() * part1.CFrame * c1 c0 = part0.CFrame:inverse() * part1.CFrame * c1

Usually unless we specifically need it for something c1 is set to CFrame.new() meaning:

c0 = part0.CFrame:inverse() * part1.CFrame

So there you go! You now can manipulate welds to solve so that they maintains the constraint between part0 and part1's world space at the time of using the above equation(s).

Log in to vote

0
I can't tell exactly what the problem is from your description, but I'm pretty sure something like this should fix it. Try using CFrame.Angles instead of Rotation.

v.CFrame = v.CFrame * CFrame.Angles(0, 90, 0) local LeftArm=Character:WaitForChild('Left Arm') local w = Instance.new("Weld", LeftArm) w.Part0 = v w.Part1 = LeftArm v.Parent = LeftArm w.C0 = CFrame.new(-0.7, 0.5, 0.25)

I haven't tried this because I don't have enough information to exactly replicate what you're doing.

0

unfortunately it does not work, and what more information ddo you need? NetworkMan243 60 — 3y