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

How do you make a CFrame rotation slower for your door?

Asked by 4 years ago

So I've made a door CFrame rotation, but I can't get it to open slower. I knew that using the Enum.EasingStyle wouldn't help but I tried it anyways. I've also tried using simple wait commands, but either I'm not putting them in the right place or it doesn't work. Here is my code:

local tween = game:GetService("TweenService")

local center = script.Parent.Center
local door = "closed"

local CF = Instance.new("CFrameValue")
CF.Value = center.CFrame

CF.Changed:Connect(function()
    center.CFrame = CF.Value
end)

local debounce = false
script.Parent.Door.ClickDetector.MouseClick:Connect(function()
    if debounce == true then return end
    debounce = true
    if door == "closed" then
        --Open door
        tween:Create(CF, TweenInfo.new(1, Enum.EasingStyle.Quad), {Value = center.CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))}):play()
        door = "open"
    else
        --Close door
        tween:Create(CF, TweenInfo.new(1), {Value = center.CFrame * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))}):play()
        door = "closed"
    end
    wait(1)
    debounce = false
end)

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
4 years ago
Edited 4 years ago

Very simply, the first parameter you put inside of TweenInfo.new() which is in your case `1``, is the value that indicates how long it would take the tween to finish its tweening.

TweenInfo.new(5, Enum.EasingStyle.Quad) --for example, I made it do the tween for 5 seconds
0
Wow, I can't believe I didn't think of that, my mind fails me sometimes lol. Thanks! DiamondMiner199 30 — 4y
Ad

Answer this question