Alright, so I have a tank and whenever I sit in the seat, the barrel of the tank is supposed to always face the mouse. The problem is however, the whole tank moves with the barrel! FYI - The barrrel is welded to the tank, and if I unwelded the barrel, it would just fall off. How can I make the barrel face my mouse and not the rest of the tank?
This is what I used to face the barrel towards the mouse (and the rest of the tank)
function move(target)-- target is basically the mouse.Target
if script.Parent.Parent:findFirstChild("Hole") and hole:FindFirstChild("BodyGyro") then
local mp = hole
local dir = (target - mp.Position).unit
local pos = mp.Position + (dir*1)
mp.BodyGyro.cframe = CFrame.new(pos, pos + dir)
mp.BodyGyro.maxTorque = Vector3.new(9000,9000,9000)
end
end

3 comments
Use a weld to weld the gun to the tank. Then use the cframe property of the weld to rotate the gun rather than the whole model.
thank you so much i forgot you can use the weld CFrame !!
No problem