Lift Script won't work

Hello their again the users of devforum I am making this lift where it can bring you from one side to another. So far, I have encountered 2 errors.

One, the player will not move with the lift and instead just falloff.
Two, the lift will not return to its original position when its hit with a keycard.

Problem One:

Problem Two:

For nearly half an hour I have searched devforum and the developer hub for fixes to this issue but non all work

local TweenService = game:GetService("TweenService")

local ElevatorTriggered = false

local Model = script.Parent
local ActualDoor1 = Model.ElevatorReal
local FakeDoor1 = Model.ElevatorFake
local KeyCard = Model.Parent.TouchPart
local FakeKeycard = Model.FakeTouchPart

local door1Position = ActualDoor1.Position
local fakeDoor1Position = FakeDoor1.Position
local KeyCardPosition = KeyCard.Position
local FakeKeyCardPosition = FakeKeycard.Position

Model.Parent.TouchPart.Touched:Connect(function(hit)
	if ElevatorTriggered == false then
		ElevatorTriggered = true
		if hit.Parent.Name == "Keycard" then
			
			local OpenTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(15, Enum.EasingStyle.Quint), {Position = fakeDoor1Position})
			OpenTween1:Play()

			local OpenTween12 = TweenService:Create(KeyCard, TweenInfo.new(15, Enum.EasingStyle.Quint), {Position = FakeKeyCardPosition})
			OpenTween12:Play()
			
			else

				local CloseTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(15, Enum.EasingStyle.Quint), {Position = door1Position})
				CloseTween1:Play()

				local OpenTween13 = TweenService:Create(KeyCard, TweenInfo.new(15, Enum.EasingStyle.Quint), {Position = KeyCardPosition})
				OpenTween13:Play()
		end	
	end
end)

It would be appreciated if you guys could help me find this out!

You need to weld the player to the moving lift so it won’t fall off. And if you want to move the lift back to the original positions there is nothing in the script that would do that. Also your CloseTween1 and OpenTween13 which should make your lift move back only fired if you hit the key Touchpart with everything but the key card but your main problem is that the script will only work a single time because you check for if ElevatorTriggered == false then and you set it to true but never back to false so your function can only run one time.

Please note that the text is formed a bit weird as I found more mistakes while writing this post.

1 Like

had an attempt at welding
image

Alright so, I was able to weld the player whenever the lift moves but now it’ll just get stuck in position for ever. Oh and if it didn’t seem obvious it didn’t weld the player to the position it was standing on and instead just made it fly?

image

You need to create the weld once it starts moving and delete them after the lift stopped moving. I can’t tell you how at the moment because I just have my phone and I am not at home. You could look in an elevator script in the toolbox as most elevators are using welds when moving.

1 Like

I have quite litterally spent the last hour trying to figure this out and it still doesn’t help, any more recommendations?

I’ve also encountered a new error

If you’re using CFrame to do this, you could use WeldConstraint. The constraint can keep the position of the player and stay connected to the lift (even if it’s anchored). You would have to create the weld when the lift starts to move and delete it when the lift reaches its destination.

This would probably not work because I didn’t have much experience with welds at all, but try using it.

Im using tween service in this

for problem a you could use AssemblyLinearVelocity

It works with TweenService (I tried it), you just need a part for the character to connect to.

Can i supposedly connect it to a union?

Since a union is a part, you are (probably) able to connect it to a union.

Don’t listen to what the others have told you so far. They’re involuntarily misleading you.

Welding the character to the platform is tedious and besides just welding the HumanoidRootPart to the base of the platform via WeldConstraint is the only feasible way I can see that you’d be able to do that, the other alternatives are just confusing.

What you should do instead means that players can move around on the platform whilst it moves, and even jump off if they want to get out.

You can achieve this by using a Constraint, such as a Prismatic Constraint.

Here’s a video of my lift that I created using constraints:

Good luck.

1 Like

your lift needs to be physics based if you want players that stand on it to move with it

and thats easily done with AlignPosition and AlignOrientation

here is a demo project
Lift.rbxl (36.5 KB)

image

and this is the script inside the demo

local alignPosition = script.Parent.AlignPosition

while true do
	alignPosition.Position = Vector3.new(0, 2, -12)
	task.wait(10)
	alignPosition.Position = Vector3.new(0, 2, -50)
	task.wait(10)
end

That could work. But I want it so the player needs to scan a keycard in order for it to move.

just set the position of the AlignPosition when the key card is scanned

local alignPosition = script.Parent.AlignPosition
local alignOrientation = script.Parent.AlignOrientation
local targets = {workspace.Target1, workspace.Target2, workspace.Target3}
local index = 1

local function KeyCardScaned()
	-- add 1 the the index
	index += 1
	-- if the index is grater then the amount of targets then wrap index back to 1
	if index > #targets then index = 1 end
	-- set align position to be the same position as the target part
	alignPosition.Position = targets[index].Position
	-- set align orientation to have the same cframe as the target part
	alignOrientation.CFrame = targets[index].CFrame
end