I want to make animated part that starts while loop and makes part move in X axis, and stops the part when its in position i want it to be, something like this
(code below is an example)
1 | local blah = game.workspace.blah |
2 | blah.Touched:Connect( function () |
3 | while true do |
4 | blah.position = vector 3. new( 0 , 0 , 0 ) + 1 -- in x axis only |
5 | if blah.position = = vector 3. new( 100 , 0 , 0 ) then |
6 | stop loop and dont let the part move |
7 | end |
Sorry for my english
Hi, dunno if you'll see this but it seems you want a tween. If you don't know what a tween is, then i recommend to look here. Now, lets work coding on it.
01 | -- Services -- |
02 | local twService = game:GetService( "TweenService" ) |
03 |
04 | -- Variables -- |
05 | local blah = script.Parent |
06 |
07 | local info = TweenInfo.new( |
08 | 10 , -- How long it should play. |
09 | Enum.EasingStyle.Linear, -- How it should move. |
10 | Enum.EasingDirection.In, -- Direction of how to tween. |
11 | 0 , -- Re-Playing it, 0 means no re-playing. |
12 | false , -- Should it do back to it's original position? For this no. |
13 | 0 -- How long will the script wait until executing the info. |
14 | ) |
15 |
Hopefully I could help you. If it doesn't work like you wanted, you can tell me. Possibly I can help you, g'day.