Trying to make a knob that goes down and up when the proximity prompt is triggered while following the door.
Have been working on this for many hours and just can’t seem to get it. Either the tween service messes up (doesn’t follow the door) or the whole door just does weird stuff (quite funny results).
I’ve tried tween service, lerping with an in pairs loop, using run service to constantly have the knob’s cframe to a certain position, welding, but none of them work so I would really appreciate some help.
Here’s the current code in a local script under StarterCharacterScripts that handles the door:
local ts = game:GetService('TweenService')
local rs = game:GetService('RunService')
local door = workspace.door.doorMain
local hinge = door.Parent.Hinge
local prompt = door.Parent.knob.ProximityPrompt
local knob = door.Parent.knob
local c = 0
local goalFront = {}
goalFront.CFrame = hinge.CFrame * CFrame.Angles(math.rad(90), 0, 0)
local goalBack = {}
goalBack.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
local ti = TweenInfo.new(
1.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out
)
local front = ts:Create(hinge, ti, goalFront)
local back = ts:Create(hinge, ti, goalBack)
prompt.Triggered:Connect(function()
c = c + 1
front:Play()
if c == 2 then
c = 0
back:Play()
end
end)
As well as what I’ve achieved so far:
robloxapp-20221016-2210285.wmv (1.9 MB)
If you look closely in the video provided the door knob does not move down and up which is the thing I want to achieve, any help on how I can do it would be appreciated.