Automatic elevator script not working

What do you want to achieve? An elevator that has no buttons and automatically goes between floor two and floors one
What is the issue? The function will not work and the elevator will not go to floor 2


What solutions have you tried so far? I couldn’t find anything relating to a problem like this

I am very new to scripting and don’t know a lot, I took some assets from a normal elevator script that has up and down buttons and put in what I thought would work. So sorry if this is an easy solution and i’m dumb lol thanks

The tweenservice instances to start need use gotolevel1:Play() and i think you should need something here like than

function gotolevel2()
gotolevel2:Play()
end
function gotolevel1()
gotolevel1:Play()
end
gotolevel2()
wait(5)
gotolevel1()

image

(My english is a little bad but if you cant understand you can respond this)

I tried to run the script but it gives me an error saying
19:40:06.493 Workspace.Model.Part.Script:10: attempt to index function with ‘Play’
Also your English is pretty good

Send a screenshot and the script with ```


here you go

That’s not how you use functions, and Tweens are played using tween:Play()
Here’s the correct way of doing it:

wait(5)
gotolevel2:Play()
wait(5)
gotolevel1:Play()

I think you are missing a while loop as well, because this will only run once and never again, so you should consider doing it.

This seems to work, but once it reaches level 2 it doesnt stay there for 5 seconds, how can I fix that?

Obviously this not are the best form to use tweens but i believed what he need with functions but now i gonna send a place with a basic elevator

elevator place.rbxl (31,2 KB)

here the place with the basic elevator

(The unique error are you should ve use cframes to move the elevator with the parts welded)

That is because when you joined, the script was already running for some time, so the 5 seconds was from when the server started, not from when you (player) joined. You can wait until the player joined, then waiting for 5 more seconds.

game:GetService("Players").PlayerAdded:Wait()
wait(5)
-- rest of code

I do not understand what you are trying to say. Best form to use tweens? What’s that?

Anyways this code you provided does not work at all because you overwrote the variable gotolevel1 and gotolevel2, which is both the tweens. If you try running this code out it will probably result in a “Attempt to index nil” error because there is not .Play property on a function.