So I am trying to make a drag able part that the player can drag up and down, but it needs to stay along a set path. I can't see to find a name to what kind of lever I am trying to make. But it's similar to a volume button where you turn it one way to increase the volume, and the other way to decrease the volume. Except here the player drags it up or down. I thought about just taking the y value of the mouse then move the part up or down based on that, but this sounds like a dirty work around as it wont work very well if I lay it flat and it will be more or less sensitive depending on the angle of the lever. So how would I have the part drag along one axis only?
after not getting a response for a while I figured it out;
function Moved() if Interacting then --True if dragging part --Base is the center --Target is the mouse.target local Change = Base.CFrame:toObjectSpace(Mouse.Hit).p --Finds how far the mouse is from the drag-able knob if Change.Magnitude <= 1 then -- 1 is just how far it can go in either direction Target.CFrame = Base.CFrame:toWorldSpace(CFrame.new(Change.x,0,0)) else Target.CFrame = Base.CFrame:toWorldSpace(CFrame.new(1*math.sign(Change.x),0,0)) end end end
this works even when it is laid flat, now I am just wondering if there is an easier way to do it?