I have a code that defines a function called playOpeningAnimation
which takes a doorBody
parameter as input. When this function is called, it sets a finish
value based on the CFrame of the doorBody
’s primary part and a rotation value of 120 degrees in the x-axis.
Then, the function executes a loop where it gradually moves the doorBody
from its current position to the finish
position using the Lerp
method. The loop increments i
by 0.07 until i
reaches 0.5, which determines the speed of the door opening animation.
During each iteration of the loop, the doorBody
’s CFrame is set to the new interpolated value using the SetPrimaryPartCFrame
method. Finally, the wait()
function is used to delay the animation by a small amount of time before the next iteration of the loop.
How can I make a door open gradually, based on how long the player holds down the interaction key (E in this case)? Can you provide an example Lua script to achieve this effect? I tried to implement with ProximityPrompt, but failed.