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)
@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.
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.
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.