How do I make a lever handle move when unanchored?

I am trying to make a moving lever handle for a building game I’m making, but I don’t know how to do it. It needs to be able to work with it being anchored and unanchored.

I tried using motor6Ds but it just makes the handle fall when unanchored.

I want to also make it tween for realistic movement.

Example (Build A Boat For Treasure)


This might be using hinge constraints but I don’t know how to use those without the part falling.

Any advice on how to achieve this is appreciated! :blowfish:

easiest solution to this is just to add 2 invisible parts for cframe reference and just tween the lever between them based on the state (off/on)

reference image: transparent parts are invisible parts for positioning, red part is lever itself (ofcourse you want to set the lever at either on or off and not at center as i show here)

local TweenService = game:GetService("TweenService")

local part = whatever

function ChangeState(state)
	
	local pickedCFrame = nil
	
	if state == "on" then
		
		pickedCFrame = part.OnCframe.CFrame
	
	else
		
		pickedCFrame = part.OffCframe.CFrame
		
	end

	TweenService:Create(part, tweeninfo, {CFrame = pickedCFrame}):Play()
	
	
end


I don’t know how to do that if the part is welded though.

it should still work tho isn’t it?

nvm it doesnt, thought it would wait a sec

Alr, I did some testing and I am able to change the position of the handle by using a normal weld and changing its C0 property. Still trying to get the positions right though

1 Like

i just forgot in a moment that the primary part wont be anchored, so yeah you should tween the weld/motor itself

Heres what I have so far. (I don’t really know how welds work)
I set the C0 which moves the part and doesnt fall when unanchored.
I don’t know how to make it go to the exact positions of the point A and B parts.

you can just take weld position references under the invisible parts

Alright, I got it to work

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.