Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make this door opening/closing animation faster?

Chest = script.Parent
Lid = Chest.Lid
Lid.PrimaryPart = Lid.Hinge

increment = 96
debounce = false

function rotate(model, amount)
        for i=1, math.abs(amount/1.7) do
            model:SetPrimaryPartCFrame(model.Hinge.CFrame * CFrame.fromEulerAnglesXYZ(0,math.pi/amount,0))
            wait()
        end
end

function openChest()
    print("Clicked on handle.")

    if not debounce then
        debounce = true
        if Chest.Open.Value then
            rotate(Lid, increment)
        else
            rotate(Lid, -increment)
        end
        Chest.Open.Value = not Chest.Open.Value
        debounce = false
    else
    end
end

for i,v in pairs(Lid:GetChildren()) do
    if v.Name == "ClickSensor" then
        v.ClickEvent.OnServerEvent:connect(openChest)
    end
end

--This chest uses a script that makes ClickDetectors compatible with FilteringEnabled.

I'm unsure how to make the speed of the door opening faster

1 comment

0

Change 1.7 to something else

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.