Elevator not working

  1. What do you want to achieve? Simply get my elevator to work for a Star Wars RP.

  2. What is the issue? ``local debounce = false
    local Touched = script.Parent

script.Parent.Touched:connect(function(Touched)
if Touched.Parent:FindFirstChild(“Humanoid”) then
if not debounce then
debounce = true
for i = 1,30 do
script.Parent.CFrame = CFrame.new(script.Parent.Position + Vector3.new(0,0.562,0))
wait(0.0001)
end
wait(2)
debounce = false
end
end
end)``

That is my script.

Inside the explorer: image

image

  1. What solutions have you tried so far? I tried to switch up the script, mess with the group. I don’t know if the union is messing the script up

Thank you in advanced

What is the issue? You’ve provided us with code but we don’t know what isn’t working.

@fireboltofdeath It’s in the post

Yes, the code is in the post, but what is your issue? What is wrong with the code? Which part of it doesn’t work?

@fireboltofdeath That’s why I’m asking, I don’t know what is wrong with the code. Here is an in game image of it not working

https://gyazo.com/296bd541f73557364bc2a59e51314f69

image

That’s the only error in the output window

That error is necessary information for the post. Your issue is your script is parented to a model. Models do not have a .Touched event, or a .CFrame property. You’ll have to use .Touched on a seperate part inside of the elevator, and use SetPrimaryPartCFrame for moving the model.

I don’t recommend using CFrame for elevators, since players will not move with it. Using constraints is what I personally do but any physics-based solution will work too.

2 Likes

Or you could make a main /base part for the elevator or use your script in the main part/union that moves

A good solution would be to use a RodConstraint

local tweenService = game:GetService("TweenService")

local tween = tweenService:Create(Rods, TweenInfo.new(2.90, Enum.EasingStyle.Linear), {Length = 1})

tween:Play()
tween.Completed:Wait()

not mine

2 Likes

I was going to suggest using a body position component.

Then just loop until it’s position is greater than or equal to it’s destination.

Please indent your code so it’s easier for us to read it using ```lua.

If you want to trigger the function when any part in the model is touched you can use GetChildren to loop through and get all parts in the model.

You can read about GetChildren() here

I wouldn’t recommend doing touched on all parts, as you’d only want the elevator to move when you’re on the top of it. Maybe an invisible part that detects you’ve entered somewhere in the middle of the upper platform, indicating a player is on the elevator, and not beside it.

Your script is parented to a Model
CFrame is not a property of Model… it’s a property of a BasePart !!!

Just parent the script to the union you want to move and everything will be fine!!!

edit: not everything… you should add some code to move down the elevator…