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: This involves loops..

Previous Thread :: Next Thread 
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:13 AM
while true do
for i,v in pairs(script.Parent:GetChildren()) do
for i = 1,25 do
wait()
v.Position = Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0)
end
end
end
It moves but it' a model. I want the whole model to move together.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
22 Oct 2011 11:15 AM
Don't trust me?

I said use Model:TranslateBy()
Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
22 Oct 2011 11:15 AM
while true do
for i,v in pairs(script.Parent:GetChildren()) do
for i = 1, 25 do
wait()
v.move( Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0))
end
end
end
That should work if not sorreh.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:17 AM
Josh

I know your trying but...no...

@Darkmist

I never heard that :P I'm new to that.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:18 AM
@Darkmist

You mean this?

v:TranslateBy (Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0)
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
22 Oct 2011 11:18 AM
Shifts a model using its offset.
This will shift a model over 10 studs.

game.Workspace.Model:TranslateBy(Vector3.new(10, 0, 0))
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
22 Oct 2011 11:19 AM
@miz,

How am I supposed to know,
The only knowledge I have is copy and paste :D
Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
22 Oct 2011 11:20 AM
But if it's alrerady grouped into a model you can take the pairs out and just tag the whole model with a varieable and use the move function?
Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
22 Oct 2011 11:24 AM
This would work right miz? cause ive been using the move function alot and it's been working for me with moving models.
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
22 Oct 2011 11:27 AM
The model doesn't have a move() function... it has a MoveTo() function?

while true do
for i = 1,25 do
wait()
script.Parent:MoveTo(Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0))
end
end

The issue with the original script was you structured your loops wrong.

You had it go through every brick in the model and move it up 25 studs.
You wanted it to move the model up 25 studs, moving the model as one.

Since that explanation was indecipherable - this is what the script would've looked like.

while true do
for i = 1,25 do
wait()
for i,v in pairs(script.Parent:GetChildren()) do
v.Position = Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0)
end
end
end
Report Abuse
joshrocks101 is not online. joshrocks101
Joined: 07 Jun 2011
Total Posts: 1712
22 Oct 2011 11:29 AM
@ ^ either way lol move() woulden't work but the moveto should
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:32 AM
@Swaniac

That's what I've been trying to tell josh.

Also, that just moved to a position.
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
22 Oct 2011 11:34 AM
My script should work,

while true do
for i = 1,25 do
wait()
for i,v in pairs(script.Parent:GetChildren()) do
v.Position = Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0)
end
end
end

This one wouldn't, in retrospect, because the script would hit a non-brick object and break.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:36 AM
And @Swmaniac

When I tried saying game.Workspace.Witch:GetChildren() only 2 of the parts moved and they just spazzmed.
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
22 Oct 2011 11:37 AM
You used this?

while true do
for i = 1,25 do
wait()
workspace.Witch:MoveTo(Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0))
end
end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:37 AM
@Swmaniac

When I tried that this is the output

Position is not a valid member of Script

Which makes sense. So I've tried saying game.Workspace but only 2 parts moved.
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
22 Oct 2011 11:39 AM
My script never uses Position, you're not using this:
while true do
for i = 1,25 do
wait()
script.Parent:MoveTo(Vector3.new(-179.7, 4.36, 82.5) + Vector3.new(i, 0, 0))
end
end
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:40 AM
@swmaniac

Thanks! That worked! I just got confused because darkmist said to use

model:TranslateBy()

And I've never heard that. But thanks!
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
22 Oct 2011 11:42 AM
This would be how TranslateBy() works


function Model:TranslateBy(Vector3 delta)
self:MoveTo(self:GetModelCFrame.p + delta)
end

Or if you can't read pseudo-code, it moves the model in relation to its current position.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 11:44 AM
Explain delta..
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
22 Oct 2011 11:46 AM
It's just how far the person calling TranslateBy() wants the model to move.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
22 Oct 2011 12:15 PM
Mkay I see now. I KINDA get it but thanks!
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