1 | local from = Camera.CoordinateFrame.p |
2 | local to = mouse.Hit.p |
3 | local ignore = { workspace } |
4 | local ray = Ray.new( from, (to - from).unit * 1000 ) |
5 | local newTarget, newHit = workspace:FindPartOnRayWithIgnoreList(ray, ignore) |
6 | local hrp = plr.Character:WaitForChild( "HumanoidRootPart" ) |
7 | hrp.CFrame = CFrame.new(hrp.Position, newHit - Vector 3. new( 0 ,newHit.Y, 0 ) + Vector 3. new( 0 , hrp.Position.Y, 0 ) ) |
The ray in the script above is applied to the LocalPlayer's HumanoidRootPart every Step and looks something like this
all nice and dandy, right? ok now the problem is this.
1 | local tween = game:GetService( "TweenService" ):Create(part, tweenInfo, { Position = plr.Character.Head.CFrame.lookVector * 250 } ) |
2 | tween:Play() |
if I try to tween a part according to the head's lookVector it works fine... as long as I don't press A, S or D.
If I press either of them the lookVector goes off-track, despite the animation playing and the head being straight in place.
This is it normally (how it's supposed to be)
And this is how it is when you press A, S or D
Extra notes: This happens to all parts, including LowerTorso, UpperTorso, HumanoidRootPart, Head. This is not because the camera script is a localscript, I already tried executing that code in a localscript and the same thing happens with A, S, D.
I have tried a lot of things, such as Anchoring, changing the walkspeed to 0, stopping the animations, but as long as you press one of those 3 buttons the lookVector will change.
I am getting desperate because I am probably going to have to scrap the move (along with many others) or even the entire aiming system if I don't find a way to fix it.
i notice that your torso changes accordingly to the animation, so either change the animation, or even better, use the cframe of the head or the camera