How can i make this part move back and forth?

Hi, I’m new to using prismatic constraints so here’s my issue:

Im trying to make the diamond plated part move towards the white part and then back to its original position again in a loop forever. I also need it to be servo (i was reccomended to use it). All of this while keeping the diamond plated part’s height from the baseplate.

My questions are: Where do the orange and yellow arrows need to be pointing to? Which part needs to have the constraint? And what do the limits have to be?

Also do i need to use a script to make it move in a loop forever?

Thanks.

aaaaaa

2 Likes

your constraint seem to be in the orientation correctly and yes I believe you would need to use a script to make it move forever

local constraint = script.Parent
local moveDistance = 5

while true do
	constraint.TargetPosition = moveDistance
	wait(5)
	constraint.TargetPosition = 0
	wait(5)
end

prismatic constraint settings
image

btw which part needs to have the constraint? Also do i gave to enable limits?

it doesn’t really matter which one has the constraint and no you don’t need to enable limits. however I would recommend anchoring the white part

diamond plate is unanchored but has can collision enabled

white part is entirely the opposite, unanchored and collisions disabled

is that ok?

collision shouldn’t matter however if you want the diamond plate to move towards the white part then anchor the white part and unanchor the diamond plate

btw does the script need to be added to the constraint or to one of the parts?

it should be added to the constraint