MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 24 Mar 2014 08:40 PM |
So I made this... It makes the Players spawn in random spots on the Baseplate when I do scramble(game.Players), but I was wondering, because I've been thinking... How would I do this so they don't spawn within say, 30 studs of each other? I've thought of measuring distance with (torso1.Position - torso2.Position).magnitude > 30, but I can't think of how to plausibly use that with the following...
--------------------------------
function scramble(plrss) for _,v in pairs(plrss:GetChildren()) do if v:IsA("Player") then if v.Character:FindFirstChild("Torso") ~= nil then torso = v.Character:FindFirstChild("Torso") spawn = game.Workspace.Walls:FindFirstChild("Baseplate") szx = spawn.Size.X - 45 szy = spawn.Size.Y szz = spawn.Size.Z - 45 torso.CFrame = CFrame.new((spawn.Position.x + math.random((-szx/2), (szx/2))), (spawn.Position.y + 4), (spawn.Position.z + math.random((-szz/2), (szz/2)))) end end end end |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
| |
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 24 Mar 2014 09:21 PM |
| Bump bump bumpitty, bump bump bumpitty |
|
|
| Report Abuse |
|
|
tery215
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 3879 |
|
|
| 24 Mar 2014 09:32 PM |
make a table of players and a repetitive action to change local torso2 to the player's torso each time per the loop starting
local torso2 = nil
function scramble(plrss) for _,v in pairs(plrss:GetChildren()) do if v:IsA("Player") then if v.Character:FindFirstChild("Torso") ~= nil then torso = v.Character:FindFirstChild("Torso") spawn = game.Workspace.Walls:FindFirstChild("Baseplate") szx = spawn.Size.X - 45 szy = spawn.Size.Y szz = spawn.Size.Z - 45 repeat jerma_infection = CFrame.new((spawn.Position.x + math.random((-szx/2), (szx/2))), (spawn.Position.y + 4), (spawn.Position.z + math.random((-szz/2), (szz/2)))) for n = 1, #(game.Players:GetPlayers()), 1 do if game.Players:GetPlayers()[n].Character:FindFirstChild("Torso") then torso2 = game.Players:GetPlayers()[n].Character.Torso if (Vector3.new(jerma_infection.X, jerma_infection.Y, jerma_infection.Z) - torso2.Position).Magnitude > 30 then jerma_wins = 50 break() end end end until jerma_wins end end end end |
|
|
| Report Abuse |
|
|