Trying to make a doorknob that goes down and up (with a tween) when the door is opened while following the door.
I’ve been trying for days now and just can’t seem to make it so as the last resort I’ve come to the DevForum.
Tried runservice (to constantly have it in a certain place), lerping (with an in pairs loop) practically everything, but one thing that I’m really curious about is if I can move only one part in a weld (not a weldconstraint) also maybe if it’s possible how can I make it so that the part0 doesn’t change cframe (position/rotation) after welding. I have also tried the Weld.C0 property of the weld like this:
Weld.C0 = downKnob.CFrame -- a cframe of the knob tilted down so it tweens down
or
Weld.C0 = knob.CFrame -- or CFrame.new() with the cframe of where i want the knob to be
but it seems to mess it up even more.
In short if anyone has a clue or two about how can I move only one part in a weld (not a weld constraint) it’d be very nice. Also here’s my door code that open and closes the door for no reason:
local ts = game:GetService('TweenService')
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 = {
CFrame = hinge.CFrame * CFrame.Angles(math.rad(90), 0, 0)
}
local goalBack = {
CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)
}
local ti = TweenInfo.new(
2,
Enum.EasingStyle.Cubic,
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)
I’m not certain if this would fix the issue, but you could add an invisible part where the door handle is. Weld the parts of the door handle to this invisible part, and then weld the invisible part to the door itself (or, the part of the door that rotates). Then, just rotate the invisible part however you’d like
Also, I think you could have a .Changed event on the door’s position, so that you can use a calculation to move the handle based on the door’s position
But actually you should be able to tween the handle and tween the door.
Not sure really what problem you are having.
I just noticed you are trying to get rotation while tweening the handles cframe, I would put a HingeConstraint, and tween that to get the handle to turn
Also, when I said send me a place file, I am not trying to get your project, I thought you might have some little test place with only the door, just to test the mechanics, sort of like I posted on this …
I think you can just change Weld.C1 to change the offset
that way you won’t have to worry about following the door around or tracking start/end positions
Yeah that was what I wanted (modified the script to my likings) and thanks a lot. I really didn’t I could’ve used a hinge like that especially didn’t know the property HingeConstraint.TargetAngle.