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: Does MoveTo Have to Use Coordinates?

Previous Thread :: Next Thread 
Solotaire is not online. Solotaire
Joined: 30 Jul 2009
Total Posts: 30356
03 Mar 2012 06:53 PM
Say that I wanted to move all the characters to a certain brick. Could I use something like
local player = game.Players:GetPlayers()
for i = 1, #player do
player[i].Character:MoveTo(game.Workspace.BrickNameHere)
?
If not, how should I do it? Also, would there be a way to randomize areas that all the players go to? From what I understand, "or" is only used during if statements, so I couldn't say something like
player[i].Character:MoveTo(Vector3.new(-1, 0, 53)) or player[i].Character:MoveTo(Vector3.new(-7, 0, 93))
etc, could I?

Any help would be appreciated. Sorry for not understanding this very well.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
03 Mar 2012 06:54 PM
MoveTo(Brick.Position)



All BaseParts (Parts, SpawnLocations, WedgeParts, etc) have a Position property. This is the coordinate the part is located at.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
03 Mar 2012 06:56 PM
Also, to choose a random position from many, you could do this:


local PositionList = {
    Vector3.new(0,0,0),
    Vector3.new(10,10,10),
    Vector3.new(0,-100,0),
}

function getRandomPosition()
    return PositionList[math.random(1, #PositionList)]
end
Report Abuse
Solotaire is not online. Solotaire
Joined: 30 Jul 2009
Total Posts: 30356
03 Mar 2012 06:59 PM
Alright, thanks a lot. Now that you mention it, I feel pretty stupid about not realizing that earlier. XD Thanks though.

I also would probably have never figured out the randomization part. Thank you for being so helpful.
Report Abuse
Maelstronomer is not online. Maelstronomer
Joined: 07 Jun 2008
Total Posts: 7649
03 Mar 2012 07:04 PM
Will this work for moving a part to another parts too? With my very limited knowledge I thought using cframe.position was the only way to do that.
Report Abuse
Solotaire is not online. Solotaire
Joined: 30 Jul 2009
Total Posts: 30356
03 Mar 2012 07:13 PM
@Maelstronomer,
I think so? Moving a player's character is just moving a model with multiple bricks inside of it.

---
Sorry to be more of a burden, but I want to see if this is right for assigning the players to their positions:
local player = game.Players.GetPlayers()
for i = 1, #player do
local PositionList = {
workspace.Brick1.Position,
workspace.Brick2.Position,
workspace.Brick3.Position,
workspace.Brick4.Position
}

function toRandomPosition()
player[i].Character:MoveTo(PositionList[math.random(1, #PositionList)])
end

It's probably wrong, so I guess I need more help. Sorry. :/

Report Abuse
Maelstronomer is not online. Maelstronomer
Joined: 07 Jun 2008
Total Posts: 7649
03 Mar 2012 07:18 PM
Have you tried testing that script? You could probably try it in solo.

Oh, and, I thought I read somewhere that using CFrame makes the part go IN whatever part it was sent to, as opposed to hitting it and moving up above it like the copy/drag btools.
Report Abuse
Solotaire is not online. Solotaire
Joined: 30 Jul 2009
Total Posts: 30356
03 Mar 2012 07:29 PM
Tested in solo mode:
This part of the code is overlooked. I'm working on recreating a minigame script. I got the map selected and the timer went. However, I did not move to any of the proper areas. The script kept going anyway and then errored because I messed another part of it up, but that should be easy to fix and isn't relevant to this problem.

@Mael,
CFrame can make bricks go inside of them, MoveTo can't. If you wanted to move a brick above another one, you could use CFrame and then add one to the "Y" position.
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