Tweening Motor6Ds

Hello there. I am new to the DevForums on here, so excuse any grammatical mistakes, as English being my third language.
I was looking to tween Motor6Ds, which go from Pan and Tilt. Sadly I still have no way to make it since I’ve tried everything and gave up, ending up deleting the old code since it was all gibberish and non-working stuff inside of it.

I am already experienced with Motor6Ds.
(I don’t know how to format a code into Lua within a post so I’ll figure it out later.)
For example my code goes like this:

function script.Positions.Tilt.Tilt1.OnServerInvoke()
for i,v in pairs (game.Workspace.TaLights:GetChildren()) do
spawn(function()
v.Motors.Tilt.DesiredAngle = math.rad(45)
end)
end
end

Same goes for Pan, instead its,

v.Motors.Pan.DesiredAngle = math.rad(45)

The part where v.Motors.Tilt/Pan.DesiredAngle = math.rad(45) is, is my question. Is there any way I can tween it? Since, when the Motors hit the Angle 45, they just instantly stop, without slowing down before it hits 45, and that just kinda makes my Moving Heads kind of awful without a transition. This is kinda like math.sin() where they move smoothly and when it hits a certain angle, it goes slow, but I don’t want a math.sin loop.

If there’s anything you don’t understand within my post, I’ll try to re-explain it.

2 Likes

math.rad(45) -> 0.78539816339745
So you’d tween the Pan’s desired angle to 0.78539816339745

local TweenService = game:GetService("TweenService");

function script.Positions.Tilt.Tilt1.OnServerInvoke()
	for i,v in pairs (game.Workspace.TaLights:GetChildren()) do
		spawn(function()
			local tweenTime = 1;
			local tween = TweenService:Create(v.Motors.Tilt, TweenInfo.new(tweenTime), {DesiredAngle = math.rad(45)});;
			tween:Play();
		end)
	end
end

Thanks, I’ll try that out tomorrow morning. I’ll let you know.

1 Like

Works perfect, thanks for the help

1 Like