How do I stop this tween part from going backwards?

Before the tween of the beam plays.

What do you mean by this?

After walking towards the player the beam animation will play but the beam will tween next to the enemy

local Size = Vector3.new(154.45, 2.192, 4.115)
	local Offset = RB.Torso.CFrame * Beam.CFrame.Rotation * CFrame.new(Size.X / 2, 0, 0) -- This should move the beam forward. If it goes backwards, set Size.X / 2 to negative.
	Beam.CFrame = local Offset = RB.Torso.CFrame * Beam.CFrame.Rotation
	TS:Create(Beam, TweenInfo.new(2), {Size = Size, CFrame = Offset}):Play()
	wait(0.77)
	TS:Create(Beam, TweenInfo.new(0.4), {Transparency = 1}):Play()
	wait(0.55)
    Beam.CanTouch = false
	Beam:Destroy()

Ah, I think I know.

CFrames need to be applied in some order to produce different results. This:

CFrame.new(0, 0, 4) * CFrame.Angles(math.rad(45), 0, 0)
-- Move part before applying rotation.

Does not equate to:

CFrame.Angles(math.rad(45), 0, 0) * CFrame.new(0, 0, 4)
-- Rotate the part first, and take that into account when moving.

So, with that said, try this:

local Offset = RB.Torso.CFrame * CFrame.new(0, 0, Size.X / 2) * Beam.CFrame.Rotation

Oh yeah, and I made a copy mistake with the setting of Beam.CFrame. Use this instead:

Beam.CFrame = RB.Torso.CFrame * Beam.CFrame.Rotation

Ok so when he stands still he’s fine but when he does his attack after chasing the player for a bit it has a freak out and doesn’t work

MP4:
https://i.gyazo.com/26ce18dd3d68e86ee47f3b49e7f54cd0.mp4

I’ve fixed it some old line of code was getting in the way anyway thanks again Y_VRN I owe you!

2 Likes