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
 

Um... how would I...

Previous Thread :: Next Thread 
MattJon is not online. 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 is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
24 Mar 2014 08:44 PM
Ba-bump-a-lump
Report Abuse
MattJon is not online. MattJon
Joined: 28 Apr 2009
Total Posts: 660
24 Mar 2014 09:21 PM
Bump bump bumpitty, bump bump bumpitty
Report Abuse
tery215 is not online. 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
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