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

How do I make my arm follow the mouse and not be turned 90 degrees?

Asked by 6 years ago

I made a script to make my arm follow the mouse, i ripped most of it from a flashlight.

local player=game.Players.LocalPlayer

script.Parent.Equipped:connect(function(mouse)
    while wait() do
    local weld=player.Character.Torso["Right Shoulder"]
    local desired_p1=CFrame.new((weld.Part0.CFrame*CFrame.new(0.5,-1.5,-0.5)).p,mouse.hit.p)*CFrame.Angles(math.pi/2,0,0);
    weld.C0=CFrame.new()
    weld.C1=desired_p1:inverse()*weld.Part0.CFrame
    end
end)

It works fine, but my arm is tilted 90 degrees to the left. How do I fix this? I messed around with the CFrame.Angles area but that just makes it flail around and act weird...

Example of what is happening: http://gyazo.com/eec4a2f8ea82fccf3cbf01bdc48d61c8

Answer this question