|
| 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 |
|
|
|
| 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 |
|
|
|
| 19 Jul 2015 10:06 PM |
| Could I possible use RenderStepped or... something else? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 19 Jul 2015 10:19 PM |
| I will use Stepped, thanks. |
|
|
| Report Abuse |
|
|
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 |
|
|