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 » Scripters
Home Search
 

Re: What would be the most efficient way to do this?

Previous Thread :: Next Thread 
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
19 Jul 2015 10:02 PM
I'm using a while true do script at the moment, what would be the more efficient way of doing this:

local GetPlayers = function()
for i,v in pairs(game.Players:GetChildren()) do
if (v.Character:FindFirstChild("Torso").Position-game.Workspace.Term.Position).magnitude < 15 then
print(v.Name, v.TeamColor)
end
end

while wait(1) do
GetPlayers()
end
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
19 Jul 2015 10:04 PM
erm


i wana see this, I have had a problem with this for a long time.

ʏᴏᴜ ᴛʜᴏᴜɢʜᴛ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴅʀᴀɢ ᴍᴇ ᴛᴏ ᴛʜᴇ ʙᴏᴛᴛᴏᴍ ᴏғ ᴛʜᴇ ʟᴀᴋᴇ sᴏ ʏᴏᴜ ᴄᴏᴜʟᴅ ᴇᴀᴛ ᴍᴇ ʟᴀᴛᴇʀ... ᴡᴇʟʟ ɢᴜᴇss ᴡʜᴀᴛ ᴘᴜɴᴋ... ɪᴍ ᴀ ғɪsʜ... ᴡɪᴛʜ ʟᴇɢs
Report Abuse
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
19 Jul 2015 10:06 PM
Could I possible use RenderStepped or... something else?
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Jul 2015 10:07 PM
not renderstepped

im assuming you're doing this in a server script, and afaik renderstepped only fires on the client
Report Abuse
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
19 Jul 2015 10:12 PM
I could do it either way, I'm just looking for a more efficient way instead of using a while wait() do.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
19 Jul 2015 10:14 PM
local t = coroutine.create(function()
while wait() do
for i,v in pairs(game.Players:GetChildren()) do
if (v.Character:FindFirstChild("Torso").Position-game.Workspace.Term.Position).magnitude < 15 then
print(v.Name, v.TeamColor)
end
end
end

coroutine.resume(t)

try that?
Report Abuse
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
19 Jul 2015 10:16 PM
Eh I meant as in if anyone had a better idea of a possible event that could fire and complete the same task... I might go that route however.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
19 Jul 2015 10:17 PM
game:GetService("RunService").Stepped:connect(function()
for i,v in pairs(game.Players:GetChildren()) do
if (v.Character:FindFirstChild("Torso").Position-game.Workspace.Term.Position).magnitude < 15 then
print(v.Name, v.TeamColor)
end
end)
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Jul 2015 10:18 PM
looking on the wiki for any events that would work for your situation

you lucked out probably
Report Abuse
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
19 Jul 2015 10:19 PM
I will use Stepped, thanks.
Report Abuse
baldo46 is not online. baldo46
Joined: 28 Jul 2008
Total Posts: 1254
19 Jul 2015 11:03 PM
Add a brick and make it not CanCollide and Anchored. And used .Touched. Adjust scripts accordingly to account for the brick.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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