|
| 19 Jun 2015 12:17 AM |
Alright, I have this question when it comes to using Functions. When I wish to have something always checking a specific event I use this:
while true do wait() check() end
Is this the proper way to always keep a Function checking an item? |
|
|
| Report Abuse |
|
|
Noe13
|
  |
| Joined: 22 Aug 2009 |
| Total Posts: 8494 |
|
|
| 19 Jun 2015 12:20 AM |
Repeat?
100% of people never been in a fatal car accident. |
|
|
| Report Abuse |
|
|
Kextra
|
  |
| Joined: 16 Oct 2010 |
| Total Posts: 165 |
|
|
| 19 Jun 2015 12:21 AM |
| Post in scripting helpers, but, who cares? ATR gets alot of unrealated stuff posted lol |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 12:23 AM |
| http://web.roblox.com/Forum/ShowForum.aspx?ForumID=33 |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 12:23 AM |
@Kextra
That got deleted. Are you from 2013? |
|
|
| Report Abuse |
|
|
jpokemon
|
  |
| Joined: 25 May 2011 |
| Total Posts: 8978 |
|
|
| 19 Jun 2015 12:23 AM |
I'm unable to give you help but, I know,people who do. Search up the scripting helpers website in google. |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 12:26 AM |
So, is it proper? Well... yes, I guess. If you mean checking on, say, an item's distance from one spot, and it checks over and over until the item is out of range, I guess so. Basically, it all depends on how you are using it. If you can't think of a better solution to a problem than then, use this. However, it's better to keep as few of these as possible with as little running code as possible, because these can create lag and get messy.
Example Time!
Checking on a block to record when it moves and where it is:
local Spots = {} local ExampleBlock = WhateverYouFeelItIs ExampleBlock.Changed:connect(function() table.insert(Spots,ExampleBlock.CFrame) end)
Making a zombie that chases humans if there are some left and only runs if there are humans left, stops when there isn't but can start back up again:
local Chasing = false
function AreThereAnyHumansLeftQuestionMark() local PlayerLeft = false local players = game.Players:GetChildren() for i = 1, #players do if game.Workspace:FindFirsChild(players[i].Name) then PlayerLeft = true end end return PlayerLeft end
function KeepChasing() if Chasing then return end Chasing = true while AreThereAnyHumansLeftQuestionMark() do MoveTowardHuman() --I don't feel like making an example function involving wait(0.01) --getting all the torsos and distance/whatnot end Chasing = false end
game.Workspace.ChildAdded:connect(KeepChasing) |
|
|
| Report Abuse |
|
|
|
| 19 Jun 2015 12:28 AM |
Lol,That's checks out then! Thanks Select!
|
|
|
| Report Abuse |
|
|
| |
|