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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|