Im using the Turret Controller by dthecoolest at https://devforum.roblox.com/t/turretcontroller-cframe-based-joint-instance-mover/940387 and ive set everything up and it works great, when it works. The turret is cloned and setup on a ship, and half the time the controller successfully aims at a target and works perfectly, and the other time it just doesn't move at all. Even when I change targets or get out and back in the ship it just doesnt work.
Here is the code that utilizes the controller module:
local TurYaw = TurretController.new(Weapon.PrimaryPart.TurretYaw,require(RS.WeaponInfo).Constraints[Type.Value].BaseConstraint) local TurPitch = TurretController.new(Weapon.TurretYaw.PrimaryPart.TurretPitch,require(RS.WeaponInfo).Constraints[Type.Value].GunConstraint) RunS.Heartbeat:Connect(function(Step) Info = require(RS.WeaponInfo)[Weapon.Name][Weapon.Stats.Size.Value][Weapon.Stats.Class.Value] local Targ = Ship.Target.Value local GoalPos if Targ then GoalPos = Targ.PrimaryPart.Position TurYaw:LookAt(GoalPos,Step) TurPitch:LookAt(GoalPos,Step) end end)
There is also a weld script that runs when the turret is cloned and I was thinking that the weld script messes it up sometimes because both my turret controller script and the weld script run at the same time. Ive looked at the turret controller studio file by dthecoolest and it works 100% of the time. I have setup print statements to check if maybe it was a problem with the Targ value but its not. I am completely stumped