Please help fixing my placing system effect

I’ve made this effect but the problem is when I rotate the object the rotate effect rotates the other way please tell me how to fix this or even make it better.

Script:

local Functions = {}

Functions["MoveTween"] = function(Part, Position, Rotation)
	
	local XDifferance = Part.Position.X - Position.X
	local ZDifferance = Part.Position.Z - Position.Z
	
	print(ZDifferance)
	
	local Tween = game:GetService("TweenService")
	local Goal = {}
	Goal.CFrame = Position * CFrame.Angles(math.rad(0), math.rad(Rotation), math.rad(0))
	
	if XDifferance > 0 then
		
		Goal.CFrame = Position * CFrame.Angles(math.rad(0), math.rad(Rotation), math.rad(10))
		
	elseif XDifferance < 0 then
		
		Goal.CFrame = Position * CFrame.Angles(math.rad(0), math.rad(Rotation), math.rad(-10))
		
	end
	
	local MainTween = Tween:Create(Part, TweenInfo.new(0.1), Goal)
	MainTween:Play()
	MainTween.Completed:Wait()
	
	local BackPos = {}
	BackPos.CFrame = Position * CFrame.Angles(math.rad(0), math.rad(Rotation), math.rad(0))
	
	local BackTween = Tween:Create(Part, TweenInfo.new(0.05), BackPos)
	BackTween:Play()
	
end

No rotation:
https://gyazo.com/c1954d6ef6883b3fcfa41efac0d4499c

With rotation (Broken):
https://gyazo.com/a68bb368e37a5e15352596815847de57

1 Like