Mesh is rotating when tweening in cframe or position

Hey
im making a script where when prompt is pressed a mesh is moving using CFrame or Position but that mesh is for no reasons rotating at 90°
heres the script :

local mesh = game.Workspace.mesh
MeshPos = CFrame.new(-9065.119, 37820.109, -5821.007)
info = TweenInfo.new(8, Enum.EasingStyle.Sine)
local ts = game:GetService("TweenService")
Prompt = script.Parent

Prompt.Triggered:Connect(function()
ts:Create(shark, info, {["CFrame"]=Sharkpos}):Play()
end)


Cframes inherently contain rotational data and positional data. When you create a new frame but don’t give it rotational data, it automatically defaults to 0,0,0.

In this case, CFrame.new(-9065.119, 37820.109, -5821.007) only has positional data and a rotational value of 0,0,0.

So you’re essentially tweening the mesh to that position and an orientation of 0,0,0.

  • since you only want to move the position, you’d just tween the position property instead.

Heres what itd look like:

local mesh = game.Workspace.mesh
MeshPos = Vector3.new(-9065.119, 37820.109, -5821.007)
info = TweenInfo.new(8, Enum.EasingStyle.Sine)
local ts = game:GetService("TweenService")
Prompt = script.Parent

Prompt.Triggered:Connect(function()
ts:Create(shark, info, {["Position"]=Sharkpos}):Play()
end)

Cframes are useful for a bunch of things. Just make sure you know when to mess with the Position property and CFrame property

1 Like

Thank you this is really clear

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.