Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a Model move Right to Left by clicking?

Asked by 11 years ago

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.

2 answers

Log in to vote
1
Answered by 11 years ago

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 
04local speed =  0.07 -- how much the brick moves each tick
05local waittime = 0.25 --How much time there is between each tick.
06X = Workspace.Model.Part.Position.X -- make sure this is the brick you based coordinates on.
07minpos = 10 --Minimum position, this is 10 in this case
08maxpos = 20 --Maximum position, this is 20 in this case
09model = Workspace.Model --the model you want to move.
10 
11function clicked()
12if X < maxpos then
13While X  < maxpos do
14model:MoveTo(X + Vector3.new(speed,0,0))
15X = X --Update the Variable
View all 29 lines...
0
Oh thank you that was helpful I get it a bit more now but how could I fix line 12? TrunksTakaski 20 — 11y
Ad
Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
11 years ago

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.

0
I'm using a If open == but it's still confusing to me, I would be thankful if you did help me out with the base script. TrunksTakaski 20 — 11y

Answer this question