How do I stop this tween part from going backwards?

I’ve beeing at this for hours now and I just can’t seem to find a fix to it and it doesn’t help that I don’t do much part tweening.

Script:

Link to the problem/video:
https://i.gyazo.com/f75deb7237c1302f08c221617f56e096.mp4

TDLR: The part is tweening backwards when I just want it to go forward.

1 Like

I dont see any issue, pls be specific.

1 Like

The part is tweening backwards when I just want it to go forward. not both ways

1 Like

Use CFrames.

local Size = Vector3.new(154.45, 2.192, 4.115)
local Offset = Your_Players_Torso.CFrame * CFrame.new(0, 0, Size.Z / 2)

Depending on where the beam should go, flip the CFrame.new(0, 0, **Size.Z / 2** to negative. Then add CFrame on the first Tween. This will work best if the character does not move.

Also, use three ` on both ends of your code to paste your code on a separate paragraph, or one of it on both ends to paste smaller snippets of code inline. To demonstrate without the post getting formatted:
image

1 Like

Sadly the character does move. (Edit: Sorry I mean the Enemy stops to do it’s attack so it does stop kinda)

1 Like

Does it stop when it starts to attack, but then moves when the beam is visible?

My only idea right now is to loop a function by Connecting to RunService.Stepped, and adjust the CFrame of the Beam.

1 Like

The enemy will start his attack and once the animation and the beam stop then he’ll start moving again.
I’ve also added your code I and don’t think it’s working although I might be doing it wrong.

image

TS:Create(Beam, TweenInfo.new(1), {Size = Size, CFrame = Offset):Play()

Create accepts a dictionary of the object’s properties with the target values.

damnit wrong post to edit

https://i.gyazo.com/235d8afbce07acfe600a5334ff48fb02.mp4

Oh no it’s spinning now.

1 Like

The CFrame’s Y value is incorrect. In the Offset variable, try adding math.rad(90) in the Y value, and test with negative or positive values.

math.rad(90)
-- OR
math.rad(-90)
-- IN
local Offset = RB.Torso.CFrame * CFrame.new(0, Put the Y value here, Size.Z / 2

Oh yeah, I also forgot that the actual length is Size.X because it is 154.45 studs long. Use that instead, and flip the X axis with - to check for its direction.

CFrame.new(0, 0, Size.X / 2) -- Change the Zto the X if it is going in the wrong direction (e.g. (Size.X / 2, 0, 0) or (-Size.X / 2, 0, 0)

why do we need the math.random?

1 Like

Yeah this isn’t working the beam keeps on flinging weirdly do you think there is a easier way of doing this?

math.rad converts degrees to radians. It is not math.random.

By that do you mean the beam spins extremely fast, or is it the same as the last clip you sent? If it’s the former, have you used math.rad? If it’s the latter, send the current code you have? (Please use the backticks for pasting code ("`"), don’t screenshot).

1 Like

it’s almost the same as the last clip I sent yes

Try this:

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.

I don’t exactly know the default rotation of the beam, so…

1 Like

Good news it looks a lot better now!
however it could use some changes

MP4:
https://i.gyazo.com/b4604372c5fc14f08011dd182d1f98ce.mp4

1 Like

The Beam isn’t exactly angled with the torso when it fires. Prior to getting the beam to animate, set its CFrame just like Offset, but without the Size offset.

Beam.CFrame = RB.Torso.CFrame * Beam.CFrame.Rotation -- This sets the CFrame of the Beam at the torso, before it gets tweened.

We’ve fixed it!

Here it is working:
https://i.gyazo.com/45d956e76ccf9f2c702d076572366d9b.mp4

Thank you so much YVRN!

This is for me for later.
image

2 Likes

It isn’t fixed :frowning: for some reason it’ll fire from the side.

where is this script meant to go?