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: Repeat problem

Previous Thread :: Next Thread 
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 11:03 AM
1.game.Workspace.CurrentCamera.CameraType = "Watch"
2.
3.while true do
4.game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(10,10,30)
5.game.Workspace.CurrentCamera.CameraSubject = game.Workspace.Part
6.wait(.1)
7.game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(10,10,30)
8.game.Workspace.Part.Position = Vector3.new(20,20,5+1)
9.wait(.1)
10.end
----------------------------------------------------------------------------------------------------

Line 8 needs to be repeated ( I am still quite new with RBX Lua. )
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
13 Dec 2011 11:05 AM
In the script did you put the
1.
2.
3.
4.
??
Because I don't think you can do that.
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 11:08 AM
Yes I did to make it easier to explain.
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
13 Dec 2011 11:10 AM
I think this is what you want.

game.Workspace.CurrentCamera.CameraType = "Watch"
game.Workspace.Part.Position = Vector3.new(20,20,5)

while true do
game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(10,10,30)
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.Part
wait(.1)
game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(10,10,30)
game.Workspace.Part.Position = game.Workspace.Part.Position + Vector3.new(0,0,1)
wait(.1)
end

That way it moves with every time the loop runs.
Using this:
game.Workspace.Part.Position = Vector3.new(20,20,5+1)
just repeatedly sets the position of the brick to Vector3.new(20,20,6)

But if you use this:
game.Workspace.Part.Position = game.Workspace.Part.Position + Vector3.new(0,0,1)
It continuously adds Vector3.new(0,0,1) to the part's position every time it loops.

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
13 Dec 2011 11:10 AM
So your saying the script looks like
1.print("Hello")
2.print("bye")

not

print("Hello")
print("bye")

I'm not sure if you can do that....
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 11:19 AM
@scarfacial, that almost solves my problem ( Thank you anyway )
But I want a starting point and a ending point.
Like it repeats for 15 times till it stops.
Report Abuse
Diebrox is not online. Diebrox
Joined: 17 Sep 2009
Total Posts: 4716
13 Dec 2011 11:26 AM
for i=1,15 do
--stuff
end
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
13 Dec 2011 11:26 AM
Ah, in that case you'll want to use a numeric for loop.

game.Workspace.CurrentCamera.CameraType = "Watch"
game.Workspace.Part.Position = Vector3.new(20,20,5)

-- I don't think you need to include the next two lines in the loop
game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(10,10,30)
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.Part

for i=1, 15 do
game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(10,10,30)
game.Workspace.Part.Position = game.Workspace.Part.Position + Vector3.new(0,0,1)
wait(.1)
end

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
13 Dec 2011 11:27 AM
Yeah... that >.>

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 11:29 AM
Ah, ok, so 'for i=1, 15 do' repeats everything beneath it 15 times?
Report Abuse
Diebrox is not online. Diebrox
Joined: 17 Sep 2009
Total Posts: 4716
13 Dec 2011 11:30 AM
Yep, you can change 15 to whatever you want depending how many times it should loop.
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
13 Dec 2011 11:30 AM
Yes make sure you have a end though.
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
13 Dec 2011 11:30 AM
Yup.

for var1, var2, var3 do
-- stuff
end

In this case, var1 would be the starting number, var2 would be the ending number, and var 3 (optional) would be the number it increments by. If you don't use a third variable it defaults to 1.

"I WILL GIVE YOU BACON." - Deadmau5
~Scarfacial
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 11:36 AM
Ah, thank you very much for your time, but there is just 1 problem I have left;
I want the camera to follow the brick but also to stay 15 studs away from it all the time. ( if that is to much of work/ a question, I will understand, thank you anyway)
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 01:10 PM
Could anyone else please help me with this 'follow' problem.
It would be much appriciated.
Report Abuse
wuppii is not online. wuppii
Joined: 20 Feb 2010
Total Posts: 1625
13 Dec 2011 01:30 PM
Anyone?
Report Abuse
WhoBloxedWho is not online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
13 Dec 2011 02:15 PM
game.Workspace.CurrentCamera.CoordinateFrame = game.Workspace.Part.CFrame. * CFrame.new(15,0,0)


Should make it follow the part, 15 studs away on the X axis.
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
13 Dec 2011 02:21 PM
Try this:

    local repetitions = 10 -- change the number to the # of times to repeat line 8
    local cam = game.Workspace.CurrentCamera
    
    cam.CameraType = "Watch"
    
    while true do
    cam.CoordinateFrame = CFrame.new(10, 10, 30)
    cam.CameraSubject = game.Workspace.Part
    wait(.1)
    cam.CoordinateFrame = CFrame.new(10, 10, 30)
    for i = 5, 5+repetitions do
    game.Workspace.Part.Position = Vector3.new(20, 20, i)
    wait(0.1
    end
    wait()
    end


----------
    ~ pwnedu46, the unicorn ~
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