Prismatic Constraint Not Working!

Hello!

I need help with my game. I created an elevator using prismatic constraints but the part isn’t moving! I did everything correct but it still won’t move. I code the moving part from a script so here is that script:

‘’’
local Players = game:GetService(“Players”)

local replicatedStorage = game:GetService(“ReplicatedStorage”)
local elevatorEvent = replicatedStorage:WaitForChild(“Elevator”)

local elevator = script.Parent
local prismatic = elevator.Shaft.PrismaticConstraint
local gui = elevator.Screen.SurfaceGui
local playersWaiting = {}
local countdownRunning = false

local function MoveElevator()
print(“Moving!”)
prismatic.TargetPosition = -20
task.wait(10)
prismatic.TargetPosition = 0
end

local function runCountdown()
countdownRunning = true
for i = 10, 1, -1 do
gui.Status.Text = “Starting in “…i…” seconds!”
task.wait(1)
if #playersWaiting < 1 then
countdownRunning = false
return
end
end
MoveElevator()
countdownRunning = false
end

elevator.Entrance.Touched:Connect(function(part)
local player = Players:GetPlayerFromCharacter(part.Parent)
local isWaiting = table.find(playersWaiting, player)

if player and not isWaiting then
	table.insert(playersWaiting, player)
	player.Character.PrimaryPart.CFrame = elevator.TeleportIn.CFrame
	elevatorEvent:FireClient(player, elevator)
	if not countdownRunning then
		runCountdown()
	end
end

end)

elevatorEvent.OnServerEvent:Connect(function(player)
local isWaiting = table.find(playersWaiting, player)
if isWaiting then
table.remove(playersWaiting, isWaiting)
end

if player.Character then
	player.Character.PrimaryPart.CFrame = elevator.TeleportOut.CFrame
end

end)
‘’’

Thanks!

In the Properties of your PrismaticConstraint do you have it set to Servo?
Is the Force set to a very high number? I use a number that isn’t inf but is still absolutely huge.

Do you have any items in the elevator model that are Anchored?
Do you have all Parts in the moving elevator model Anchored false, but you have one of them welded to an anchored item outside the elevator model?
You can go to the Model tab in Studio and in the Constraints section and click on Show Welds (?), Show Constraints and Draw On Top so you can see if there’s anything weird going on.

Another thing is to go into your Studio Settings and in the Physics section click on Show Collisions to put a red sphere wherever collisions occur between Anchored false Parts. If you have too much friction to overcome, or a collision that blocks the elevator from moving you should see a red sphere at that location.
Actually I think there’s even a checkbox for ‘show anchored items’ in the settings as well, which might help you see if some part of the elevator accidentally got anchored.

Thanks for all of this @Scottifly
I have already done most of the things you said, actually.
I was wondering if the Shaft part of the elevator should be anchored or not?
The Shaft part is the part that the elevator slides on to go up or down. If this is not clear, I can send an image

One end of the PrismaticConstraint needs to connect to your moving elevator, the other end needs to be attached to whatever the elevator is moving in relation to (in your case the elevator shaft Part.

When you have the Show Constraints turned on and click on the PrismaticConstraint, or select it in the Explorer window, look at the Properties window to see if the Attachment0 and Attachment1 of the Prismatic are actually applied (meaning those 2 boxes aren’t blank). If they are applied, when you click on the Prismatic you should get a green box around the 2 Parts that the Attachments are on.

I guess another thing would be to see if you have the Limits checked off and they are inside the 10 studs you are moving the elevator.

To see if how the elevator is working try test mode and then select the prismatic constraint while playing to see if the TargetPosition value is changing to -20 when the elevator is used. If not it’s a scripting issue. If it is then it’s a building issue.

Is the Prismatic upside down? This would mean it should be +20 instead of -20. In test mode manually change the TargetPosition to 20 and then -20 to see if the elevator moves.

Have you used any Unions or MeshParts that the elevator might be colliding with? Using the ‘Show Collisions’ setting should show if you are having this issue.

Yeah, still didn’t work.

I used a tutorial to build the elevator. I made sure everything is the same as what he showed.

Here is the tutorial: Game Lobby Elevators - Tower Defense Tutorial #20 - YouTube

You answered “still didn’t work” but did you try every step?
If the PrismaticConstraint TargetPosition doesn’t change while testing then your script is the issue. Use print statements in each section of the script to print the values of the variables used in each section.

So when you change the TargetPosition of the Prismatic manually the elevator doesn’t move?
Do you have limits Enabled?
Did you try using disabling Limits (if you have them Enabled) to see if that helps?

If you look in my Models (I’m not on Roblox right now) you will see a moving platform example using Prismatic Constraints. Take a copy and check out how I got it moving and how the PrismaticConstraint is set up.