A turret I've made uses a BodyGyro
to aim its barrel at players, and then shoots a bullet towards the barrel's lookVector
. This method would work great if the hinge joints that allow the gun to rotate freely didn't break apart every other time a server is started. Is there a way to keep this from happening?
I don't think use a hinge is possible with what your doing, it might idk. But I would use a Motor hinde and set the Y C0 to the direction:
Hinge = Instance.new("Motor") Hinge.Part0 = Base Hinge.Part1 = Barrel Hinge.C0 = Base.CFrame:inverse() Hinge.C1 = Barrel.CFrame:inverse()
That should keep it connect as long as you don't CFrame it.
You can either turn it by using the DesiredAngle or C0-C1 properties. To look at all the properties and how to set them look at the wiki: http://wiki.roblox.com/index.php?title=RBX.lua.Motor_(Object)
It might be a bit confusing.