LookVector acting strangely

Hi, I have an odd problem here.

Each time this code is ran, the character will face towards the same direction if not in shiftlock (The direction is always the same, seems to be pointed at 0,0,0?), and I’m unsure of the cause.


The main code used is here^, does anybody have any advice on how to fix this? Thank’s in advance.

Since tweens are being used, they may overlap when multiple slash requests are sent simultaneously, resulting in overlapping effects.

You can use BodyVelocity

local BodyVelocity = Intance.new("BodyVelocity",root)
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Velocity = root.CFrame.LookVector * 3
task.delay(.3,function() BodyVelocity:Destroy() end)
1 Like

Isn’t body velocity supposed to be depreciated now? I’ve tried with LinearVelocity before and imo the results didn’t feel right, but i might check it out again thanks!

Hey there, this seems to be due to an oversight in your use of CFrames.
CFrames, or CoordinateFrames, contain a given parts position and rotation.
However when you are tweening, you create a new CFrame, without giving it a rotation, so it will default to (0, 0, 0). Essentially, you are resetting your character’s orientation every time you tween their position.
Instead you could change your Tween from

local tween = TweenService:Create(root, tweeninfo, {CFrame = CFrame.new(root.Position + (root.CFrame.LookVector * 3))})

To

local tween = TweenService:Create(root, tweeninfo, {CFrame = root.CFrame * CFrame.new(0,0,-3)})

Given that multiplying CFrames results in moving the part in Object space, you are still achieving the effect of moving the character 3 studs in the direction they are looking. However this way, you are creating the new CFrame with the root’s CFrame as a base, and thus keeping it’s rotation.

Hope this helps!

2 Likes

You can use ApplyImpulse.

root:ApplyImpulse(root.CFrame.LookVector * 3)

I’ll try the solutions when I’m back home, and will mark as solution accordingly; Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.