I recently made a door that can be opened with a click. It works amazingly, and it looks good, but I have one slight issue. I tried to make a tween where the door handle would move when clicking but the door handle can’t be tweened if it’s welded to something.
Issue:
- My door handle can’t move because it is welded to the door which is welded to a hinge part. If the door handle were to move it would move the whole door with it.
Workspace:
With being welded:
robloxapp-20230412-2316009.wmv (130.4 KB)
Without being welded:
robloxapp-20230412-2315032.wmv (231.9 KB)
My Code:
local TweenService = game:GetService("TweenService")
local hinge = script.Parent.DoorHinge
local ClickDetect = script.Parent.Door.ClickDetector
local HandleHinge = script.Parent.HandleHinge
--Door Hinge
local goalOpen = {}
goalOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(90), 0)
local goalClose = {}
goalClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
--Handle Hinge
local goalOpen2 = {}
goalOpen2.CFrame = HandleHinge.CFrame * CFrame.Angles(math.rad(-30), 0, 0)
local goalClose2 = {}
goalClose2.CFrame = HandleHinge.CFrame * CFrame.Angles(0, 0, 0)
local tweenInfo2 = TweenInfo.new(.5, Enum.EasingStyle.Back, Enum.EasingDirection.In)
local tweenOpen2 = TweenService:Create(HandleHinge, tweenInfo2, goalOpen2)
local tweenClose2 = TweenService:Create(HandleHinge, tweenInfo2, goalClose2)
Open = false
ClickDetect.MouseClick:Connect(function()
if Open == true then
tweenClose2:Play()
wait(.5)
tweenClose:Play()
wait(1)
Open = false
else
tweenOpen2:Play()
wait(.5)
tweenOpen:Play()
wait(1)
Open = true
end
end)
What is an alternate option I can do to make the door handle animated but also make it move with the door?