I'm trying to make a gun where your right arm follows your mouse when it's equipped. Here's what I have:
player = game.Players.LocalPlayer repeat wait() until player.Character char = player.Character shoulder = char.Torso["Right Shoulder"] original = shoulder.C0 active = false function onEquipped(mouse) active = true while active == true do shoulder.C0 = CFrame.new(shoulder.C0.p, mouse.Hit.p) wait() end end script.Parent.Equipped:connect(onEquipped) script.Parent.Unequipped:connect(function() active = false shoulder.C0 = original end)
When I try to aim forward, my arm is facing to the right of me. When I aim right, my arm points behind me. Any ideas on how I'd fix this?
I recommend checking out the math in the equip function of this flashlight, made by a Roblox employee- its setup for the right shoulder, as well. It shows a very eloquent approach, in order to avoid the issues you're running into.
http://www.roblox.com/item.aspx?setItemId=12882927&avID=272162900