arby31
|
  |
| Joined: 29 Dec 2009 |
| Total Posts: 337 |
|
|
| 18 Mar 2013 05:26 PM |
| Hey guys, quick question. I am not by any means asking you to make me script, just an example. see, I will be making an aesthetic train that comes in a tunnel and goes. I want it to loop infinitly (while true do) throughout the server. Could you maybe give me an example of a brick that would be in a loop? And another question, can a model be used with vector 3? |
|
|
| Report Abuse |
|
|
moryo7
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 5028 |
|
|
| 18 Mar 2013 05:27 PM |
"Brick that would loop"
What do you mean by this? |
|
|
| Report Abuse |
|
|
arby31
|
  |
| Joined: 29 Dec 2009 |
| Total Posts: 337 |
|
|
| 18 Mar 2013 05:29 PM |
| A brick that is stuck in a never ending loop from point A to point B (after getting from point A to point B the brick resets to A and just repeats it's process |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 18 Mar 2013 05:38 PM |
part = Workspace.part reset = 0 dest = Vector3.new(0,0,0) pos = part.Position speed = 1
while wait() do if (dest - part.Position).magnitude < 10 then part.CFrame = CFrame.new(pos) else part.CFrame = CFrame.new(part.Position + (dest-part.Position).unit*speed) end end
Sloppy, but should work...probably. Basically if 'part' comes within 10 studs of 'dest' then it resets it's position, and travels there again. |
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 18 Mar 2013 05:39 PM |
| "reset = 0 " that line doesn't need to be there. Forgive me. |
|
|
| Report Abuse |
|
|
arby31
|
  |
| Joined: 29 Dec 2009 |
| Total Posts: 337 |
|
|
| 18 Mar 2013 05:49 PM |
| Thanks, So when I type the script, should I insert it into the workspace, or model? |
|
|
| Report Abuse |
|
|
|
| 18 Mar 2013 05:53 PM |
I would probably do something like
local start=Vector3.new()--where it starts local end=Vector3.new()--where it ends
while true do for i=0,1,1/(end-start).magnitude do part.CFrame=CFrame.new(start:Lerp(end,i)) Wait() end end
|
|
|
| Report Abuse |
|
|
RoflBread
|
  |
| Joined: 18 Jun 2009 |
| Total Posts: 3803 |
|
|
| 18 Mar 2013 06:14 PM |
| Put it in the wospace and chage the variables so they point to the right brick and destination |
|
|
| Report Abuse |
|
|