function MoveBarrel()
local a = Plane.GunnerStand
local b = Plane.MovingBarrel1
local spot = Vector3.new(0,0,-a.Size.Y/2) -- Front facing because I'm too lazy to make it the front
if not gunweld then
gunweld = Instance.new("Weld")
gunweld.Parent = a
gunweld.Part0 = a
gunweld.Part1 = b
end
gunweld.C0 = CFrame.new(spot)*CFrame.new(spot,a.CFrame:inverse()*(mouse.UnitRay.Direction*10000))
end
mouse.Move:connect(MoveBarrel)
I have this. Does what I want, it makes a block point at a weird point that the mouse is pointing at in direction and perspective of camera rather than what the mouse is hitting in direction from another point. However, when moving the mouse around, the barrel rotates around, looking very odd. Like, it still points where it is supposed to, but the z axis of the brick rotates around. Help pl0x? |