Tween getting disoriented while moving towards a certain direction?

Hello,

So I’m in a super stressful situation where I have no idea how all of a sudden my tween started to move in the wrong direction when it was literally working just fine. All I’m really doing is just making a jump scare where as you’re walking through this one entrance, you touch an invisible trigger making a ball fly across the room slamming onto the wall near you.

This is how the ball is meant to move:

Simple, nothing complicated at all until now.

The code inside the trigger which makes this supposed jump scare happen:

local trigger = script.Parent
local train = game.Workspace.wallstrain
local trainsound = game.Workspace.wallstrain.trainrunning
local TweenService = game:GetService("TweenService")
local girllaughter = game.Workspace.girllaughter
local tween = TweenService:Create(train, TweenInfo.new(1.8, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = train.CFrame * CFrame.new(58.5,0,0)})
local trainhit = game.Workspace.trainbreaksound.cliphit
local force = game.Workspace.force
local Debounce = false

trigger.Touched:Connect(function(hit)
	if not Debounce then
		if hit.Parent:FindFirstChild("Humanoid") then
			tween:Play()
			force:Play()
			wait(0.03)
			trainhit:Play()
			Debounce = true
			wait(0.05)
			trainsound:Play()
			Debounce = true
			wait(1.2)
			girllaughter:Play()
			trainsound.Volume = 0.8
			wait(2)
			trainsound.Volume = 0.6
			wait(0.2)
			trainsound.Volume = 0.4
			wait(0.2)
			trainsound.Volume = 0.2
			wait(0.2)
			trainsound.Volume = 0
			wait(2)
			force:Stop()
			script:Destroy()
		end
	end   
end)

This is what the movement somehow changed to now:

It’s going the right direction but then disorients itself up while doing so???

I’ve already tried looking up this problem of tweens somehow going the wrong way but none were useful to me. I had tried messing around with the directions the tween would go but would still disorient. I’d appreciate any help as this issue is really irritating me now knowing how easy it is to get to work but is failing me. Could it be the angle things are at and I have it calculated incorrectly or something?

I wish I could help you identify your issue; however, I am a bit confused with your explanation. Much of my confusion stems from your terminology and my lack of understanding of what exactly you are trying to achieve.

Before providing any advice, I am going to outline what I picked up from your post and highlight your intentions and issues. Please correct me if I am wrong so we are on the same page.

You are creating a jump scare effect in which upon character collision with a trigger part, a ball, powered by tweens, will fly from point A to a wall. This effect is accompanied by a few sound effects. However, upon testing, the ball does not fly in the intended trajectory to due to a possible tweening error.

A couple things.

  1. Define what you mean by “disorient”. You mention that the tween is “getting disoriented” while it’s moving in a certain direction but I still do not quite understand what you mean. Are you saying that the ball changes direction? From the clip you posted, it seems more plausible to assume that you merely miscalculated your final CFrame. I do not see any evidence of the ball changing direction at any point in time; however, I may be missing something.

To check if you incorrectly calculated your CFrame, simply instantiate a new temporary part into the workspace and set its position to match what you put in your TweenService:Create() method. You do not need to do this through a script, just create and edit a part through the explorer. If the part is not positioned at the desired final location, you can conclude you simply miscalculated your final position.

  1. Personally, I would not use TweenService at all in this instance; however, I do not have too much experience with this sort of thing. In this case, I would most likely use something like ApplyImpulse or a Body Mover and let Roblox physics handle the rest. I imagine this would give the ball a more natural looking trajectory. Other people may disagree with me though, so keep an open mind to different ideas!

Hopefully some of my advice was useful. If not, feel free to reply and I will get back to you!

1 Like

Yeah that basically sums up what I was trying to say, since I’m not the best at explaining I wasn’t sure what terms would fit and used “disoriented” as in the ball was moving away from the intended direction just doing it’s own thing.

Sorry about that, it may have looked like it as I was still testing in the clip why the ball was disappearing and going through walls and made it not go not as far in the meantime to see towards what direction it was heading.

Anyways, here’s a clip in the open and made the ball move further this time:


As you see, it’s moving towards the right from this angle which is what I need, but somehow moves parallelly to the right.

This is how the ball should be moving:

I have the tween to where it supposedly should only be moving to the sides. It was working earlier, not so sure why it’s doing this now.

Am I missing something and I somehow have it to move parallelly now? Movement directions confuse me a lot.

local tween = TweenService:Create(ball, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = ball.CFrame * CFrame.new(0,6,0)})

I hope it makes sense now.

I am still a bit confused, but I think I am starting to understand a little bit better now.

One clarification I need is about your use of the term “parallel”. Parallel implies that a certain direction should match the angle/direction of something else. For example, image A in the picture below showcases parallel lines as they point in the same relative angle. Image B depicts non-parallel lines because they do not point in the same relative angle.
image
So, when you say that the ball “somehow moves parallelly to the right”, I am not fully understanding, since the image of your intended trajectory seems to fit this phrase in that the line you drew moves in a direction parallel to the right direction.

Next, the tween that you included in your reply does not seem to match anything you put in your original post. It seems to make use of a variable called “ball” but the only tween used in your original post’s code uses a variable “train” with different tween values. Are these supposed to be the same? Or are they separate?

You also mention that previously your tween worked but suddenly stopped working without your altering anything. I have no reasonable explanation for this. The only thing I can think of would be if you unknowingly changed the starting position of all your parts as this would have an effect on the ball’s resulting CFrame, but this conclusion still seems pretty far-fetched. We may be left with a mystery here, I truly do not know what could have caused this change.

Luckily, we can revert it back ourselves. Based off of what you said in the first post and now your reply, I think it is reasonable to conclude that this is a matter of CFrame miscalculation. Your tween process looks correct, but I am skeptical about how you calculated the final CFrame. I do not understand why you are multiplying the ball’s CFrame by a CFrame of (0,6,0), so this could be the reason for the error. As for a solution, I mentioned this in my previous reply but I think you should record your intended final CFrame by creating a temporary part. The following video demonstrates this concept. I have used YouTube because my video was too long to upload here lol

Hopefully, this resolves your issue. If not please reach out again, and I will try my hardest to provide more input.

Lastly, I would take a look at the following article if you haven’t already. It may help you with your understanding of CFrames.

Also…

Yeah that basically sums up what I was trying to say, since I’m not the best at explaining I wasn’t sure what terms would fit and used “disoriented” as in the ball was moving away from the intended direction just doing it’s own thing.

I relate to this completely, haha. I’ve always struggled with explaining my thoughts as well.

2 Likes

Oh sorry, I also have a train model in game which uses the same script and was trying to figure out what is so different from it that one works properly and the other doesn’t. Must’ve got confused and included something else in, sorry about that.

Yooo that was exactly what I was looking to do! Much easier than from what I was doing too. Sorry for the inconvenience with my confusing explanation throughout the past day haha. Nailed it, thanks!

1 Like

Awesome to hear! Good luck on the project!

1 Like