Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to rotate with Tween Service?

Asked by 5 years ago
Edited 5 years ago

So, I'm trying to combat door lag in my place. One of the ways of doing that is by locally scripted the doors and using TweenService.

I have a CFrame function bellow:

local offset = hinge.CFrame:inverse() * doorModel.CFrame;
for i=1,40 do
    wait()
    hinge.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(1)*i*0.1, 0)
    doorModel.CFrame = hinge.CFrame * offset 
end

My question is, that this is using just CFrame. How can I turn this into Tween Service? My attempt is bellow, but got no results:

local offset = hinge.CFrame:inverse() * doorModel.CFrame;
hinge1.CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(1)*i*0.4, 0)


local OutTween = TweenService:Create(door.Scripted.Door, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = hinge1.CFrame * offset})

OutTween:Play()

Any ideas? Thank you! ~ DrBaja

1 answer

Log in to vote
0
Answered by 5 years ago

Hello! I know this is an old post, but heres what you are doing wrong! You have hinge1.CFrame * CFrame.Angles(0, math.rad(1)*i*0.4, 0); but what is the i value for math.rad(1)*i*0.4? So to fix this we simply change i in math.rad(1)*i*0.4 to 40, so its like this math.rad(1)*40*0.4

Heres your script fixed:

local offset = hinge.CFrame:inverse() * doorModel.CFrame;
hinge1.CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(1)*40*0.4, 0)


local OutTween = TweenService:Create(door.Scripted.Door, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {CFrame = hinge1.CFrame * offset})

OutTween:Play()

If doesnt help, please do let me know, but it should.

Ad

Answer this question