I am trying to make a script that basically leads to you clicking a Model. Once the model is clicked it will move Left or if it was already left it would be Right, I tried going through the wiki but still having trouble. If you can please help me out. Thanks.
to do that, you would firstly need to know exactly between wich two coordinates a part of the model should move. we will base the script on that. only 1 of the 3 coordinates should be different.
you will probably need to do some adjustments, but imagine your part moves between (10,0,0) and (20,0,0). that would mean the X coordinate needs to change (coordinates are X,Y,Z) then you do this. i will make the script based on having a clickdetector.
01 | -- i especially made this script for easy configuring. simply change the variables at the top to fit your part. if the Coordinate is Y or Z, only change Position.X at line 3 to Position.Y or Position.Z. just keep the variable X to spare yourself time. |
02 |
03 |
04 | local speed = 0.07 -- how much the brick moves each tick |
05 | local waittime = 0.25 --How much time there is between each tick. |
06 | X = Workspace.Model.Part.Position.X -- make sure this is the brick you based coordinates on. |
07 | minpos = 10 --Minimum position, this is 10 in this case |
08 | maxpos = 20 --Maximum position, this is 20 in this case |
09 | model = Workspace.Model --the model you want to move. |
10 |
11 | function clicked() |
12 | if X < maxpos then |
13 | While X < maxpos do |
14 | model:MoveTo(X + Vector 3. new(speed, 0 , 0 )) |
15 | X = X --Update the Variable |
The way I would do it is to check it's cords, then if it's == to the last position then move it to the next.. If you need me to set up a base script for you then I will.