I bear good news, your script works great. (though not efficient)
However, it's not stopping because it will never reach 17.
1 | local gatepos = game.Workspace.Model.gate.gate 1. Position.Y - 17 |
3 | while game.Workspace.Model.gate.gate 1. Position.Y ~ = gatepos do |
4 | print (game.Workspace.Model.gate.gate 1. Position.Y) |
6 | game.Workspace.Model.gate:TranslateBy(Vector 3. new( 0 ,-. 1 , 0 )) |
I read your code, and it made perfect sense. So I turned to the famous method of printing to the output for debugging. I'm printing the gate's Y position as it goes down.
Here's a small snippet of it from a very long list:
Output
19.199983596802
19.099983215332
18.999982833862
18.899982452393
18.799982070923
18.699981689453
18.599981307983
18.499980926514
18.399980545044
18.299980163574
18.199979782104
18.099979400635
17.999979019165
17.899978637695
17.799978256226
17.699977874756
17.599977493286
17.499977111816
17.399976730347
17.299976348877
17.199975967407
17.099975585938
16.999975204468
16.899974822998
16.799974441528
16.699974060059
If you can't tell, it never hits 17. Now, you can simply round, but I'd like to help you out.
A more efficient and controlled method of achieving your desired result is to simply do this:
1 | local gate = game.Workspace:WaitForChild( "Model" ):WaitForChild( "gate" ):WaitForChild( "gate1" ) |
5 | gate.Position = Vector 3. new(gate.Position.X,gate.Position.Y - 0.1 ,gate.Position.Z) |
Voila, that achieves what you were hoping for. It will move the gate 17 studs down from its current position. For the 0.1's, you may want to create a variable called speed. But I left it like that so you could understand the script better.
You can use this same block of code to make it go up. You simply change the -0.1 to 0.1.