local X, Y, Z = absoluteTurretCFrame:ToOrientation()
local X2, Y2, Z2 = absoluteTurretCFrame:ToEulerAnglesXYZ()
local ClampedY = math.clamp(Y,Y2 - 2,Y2 + 2)
Elsewise it works great and it correctly stops on angles.
Just this turning backwards things when standing on it may be problematic, oh and it doesn’t matter if your floating above it, as long as you’re standing above this area the clamp stops working correctly.
local absoluteTurretCFrame = CFrame.new(script.Parent.Body.TurretPos.Position, Players[i].Character.HumanoidRootPart.Position)
local Test = isInAngleRange(script.Parent.HumanoidRootPart.CFrame.p, script.Parent.HumanoidRootPart.CFrame.LookVector, Players[i].Character.HumanoidRootPart.Position)
if Test then
local X, Y, Z = absoluteTurretCFrame:ToOrientation()
local X2, Y2, Z2 = absoluteTurretCFrame:ToEulerAnglesXYZ()
local ClampedX = math.clamp(X,-0.2,0.2)
local ClampedY = math.clamp(Y,Y2 - 2,Y2 + 2)
trys to make tank turret function properly Tank: NECK SNAP SOUND
but in all seriousness, it works until that very specific spot in the middle is touched, then it goes full disco depending on where you walk. (Which I assume is the clamp stopping for some reason)
I can walk to its side, or its back without any issue.
Yeah, I tested it a bit earlier and it seems the X clamp doesn’t give out, it’s the Y clamp that gives out (It still clamps correctly for X even when Y is crying)
Was experimenting around, it seems the clamp fails when it hits positive numbers, which the top is in the middle so it can hit those numbers for some reason on certain angles.
EDIT: I think its something to do with that angle code, because I removed the clamp and it still did this effect when standing right on it, but the clamp should’ve also stopped that.
FINALEDIT?: I seem to have fixed it, it was a piece of angle code that was missing a variable since it wasnt the mouse itself it was aiming at, very glitchy though but managable now.
I had to add the Y angle into the mix for it to work, so it doesn’t like it when you jump right infront of it it will immediately return false, causing it to give up on its target doing that, its a better start though as now it doesn’t rave when you jump on it, I just need to find a tweak to allow it to look slightly higher.
Jumping a small distance away has no issue, I think it just needs some small tweaks, otherwise its fine now. Thank you.
Awesome, glad to hear that! Thanks for letting me know. If you have any more difficulties with this issue coming up, feel free to respond to me here (so I get a notification).