Part does strange thing when rotating

So i want a part to rotate smoothly to orientation 0 0 0, the part is called Plate in the script so you know

(and i also want to tween the part to the size 20 2 20 but that works just fine)

But, for some reason the part is just tweening to the position 0 0 0 very fast


		local plate = workspace.Plates:FindFirstChild(tostring(randomplate))

		print(plate)

		local tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
		local goal = Vector3.new(20, 2, 20)
		local tween = Tweenservice:Create(plate, tweeninfo, {Size = goal})

		tween:Play()
		
		local found = plate:FindFirstChild("SpinningPlate") -- spinningplate is a script that may exist more than 1 and makes the part spin to a random direction forever
		if found then
			print("found")
			while found do
				found:Destroy()
				found = plate:FindFirstChild("SpinningPlate")
			end
			local rotationSpeed = 3
			local tweeninfo = TweenInfo.new(rotationSpeed, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
			local goal = {CFrame = CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))}
			local rotatePlate = Tweenservice:Create(plate, tweeninfo, goal)
			rotatePlate:Play()
		end

i did try do change the value 0 0 0 to 10 0 0 but it was still tweening to position 0 0 0

i would really apreciate any suggestions why this is happening

1 Like

You’re setting the CFrame, which represents the parts position and rotation, so it’s overwriting the position to (0, 0, 0).

You can fix this by adding the plate’s position back so it doesn’t go anywhere:

local goal = {CFrame = CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)) + plate.Position}
2 Likes

Also, why are you setting up a new set of tween parameters every single time?

local rotationSpeed = 3
local tweeninfo = TweenInfo.new(rotationSpeed, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

Just set them at the very beginning of the script and play the tween on the plate you want them to affect.

1 Like

okay thanks a lot :slightly_smiling_face: im pretty new at scripting so thats why the code may be a little rude

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