generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Playing around with vector 3 and while true do

Previous Thread :: Next Thread 
arby31 is not online. 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 is online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
BJJScrambler is not online. BJJScrambler
Joined: 13 Jan 2013
Total Posts: 898
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image