Tweening position is turning horizontal instead of vertical

I’m making a keycard machine where it opens up to something, and I’m using tweenservice but it is turning the wrong way than I expected.

Script :

game.ReplicatedStorage.remotes3.OpenMachine.OnServerEvent:Connect(function(p)
if p.Character:FindFirstChild('Keycard') or p.Backpack:FindFirstChild('Keycard') then
	local tool=p.Character:FindFirstChild('Keycard') or p.Backpack:FindFirstChild('Keycard')
	tool:Remove()
	script.Parent.Parent.Key.Place.Enabled = false
local stas = game:GetService("TweenService"):Create(
	script.Parent,
	TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),
	{
		CFrame = CFrame.new(1403.967, -184.789, 553.385)
		}
)
stas:Play()
end
end)

Video :

robloxapp-20200317-1526204.wmv (1.9 MB)
Look at the video before you reply.

The only reason the location would be wrong, is the coordinates that you set being wrong. Check them perhaps

EDIT: Person changed question

It isn’t wrong at all, it is turning horizontal instead of verical.

Would it matter or horizontal or vertical? I mean it’s spinning in a circle…

I want it to go up straight instead of it turning horizontal.

It might be something to do with your Easing Direction ? But I’m not 100% sure

I changed it to In and to Out, it didn’t work.

So you want it to go up and down? If you want that just use TweenPosition instead of rotation it using CFrame.

What do you mean by that? You can use :TweenPosition() on objects too?

TweenService:Create(part, TweenInfo.new(10), {CFrame = CFrame.new(1403, -184, 553)})

if your just wanting a basic movement, you don’t need all those extra TweenInfo properties, besides TweenTime.

@ProjectExtraction @EquivocalCrow @starmaq Seriously, seriously, please don’t reply if you don’t know the solution, as you’ll only spread incorrect information. The solution is quite simple if you know the basics of CFrames.

The reason this is happening is because CFrames contain positional data and rotational data. Whatever you’re tweening has some rotational data as part of its CFrame that you’re losing when you construct a new CFrame as part of the tween. Consider transforming the original CFrame instead of constructing a brand new one to solve your issue.

3 Likes

I know a lot about CFrame. The way the question was worded changed entierly since the first time I read through. At first it didn’t even mention “turning horizonatlly instead of vertically”, it just said “tweening location is wrong” or something along those lines, which didn’t explain much.

How would I do that? Do I use Position instead of CFrame?

Try to use this instead

CFrame = CFrame.new(-184.789, 553.385,1403.967)

Or this:

CFrame = CFrame.new(553.385, 1403.967, -184.789)

Some numbers are changed, only that, I hope this help you

Definitely don’t do that.

In order to transform the CFrame, instead of doing:
CFrame = CFrame.new(1403.967, -184.789, 553.385)
Do:
CFrame = script.Parent.CFrame + Vector3.new(OffsetX, OffsetY, OffsetZ)
If you want to transform it in world space, or:
CFrame = script.Parent.CFrame * CFrame.new(OffsetX, OffsetY, OffsetZ)
If you want to transform it in local space.

1 Like

I thought that would be the same thing doing this:

and this:

I prefer that instead of quoting me, tell OP that he just made this wrong because I just have copied his code, I just have changed some numbers.

Thanks, sorry for the late respone.