When I click a model moves to 1,1,1 but when I click again, I want the model to move where it was before you clicked the first time.
1 | Part = script.Parent |
2 | Model = game.Workspace:WaitForChild( "Model" ) |
3 |
4 | Part.ClickDetector.MouseClick:connect( function () |
5 | Model:MoveTo(Vector 3. new( 1 , 1 , 1 )) |
6 | end ) |
You need to save the coordinates of where it was in the first place
01 | local x, y, z = 0 , 0 , 0 |
02 |
03 | part.ClickDetector.MouseClick:connect( function () |
04 | if Model.Position.X ~ = 1 and Model.Position.Y ~ = 1 and Model.Position.Z ~ = 1 then |
05 | x = Model.Position.X |
06 | y = Model.Position.Y |
07 | z = Model.Position.Z |
08 |
09 | Model:MoveTo(Vector 3. new( 1 , 1 , 1 )) |
10 | else |
11 | Model:MoveTo(Vector 3. new(x,y,z)) |
12 | end |
13 | end ) |