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 » Roblox » All Things ROBLOX
Home Search
 

Re: Firing a Function

Previous Thread :: Next Thread 
catnip6362 is not online. catnip6362
Joined: 23 Nov 2008
Total Posts: 438
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 is not online. 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 is not online. 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
CrispyCrunchyZach is not online. CrispyCrunchyZach
Joined: 02 Jan 2014
Total Posts: 2673
19 Jun 2015 12:23 AM
http://web.roblox.com/Forum/ShowForum.aspx?ForumID=33
Report Abuse
zachattack220 is not online. zachattack220
Joined: 20 Jan 2013
Total Posts: 2196
19 Jun 2015 12:23 AM
@Kextra

That got deleted. Are you from 2013?
Report Abuse
jpokemon is not online. 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
Selectivemontay is not online. Selectivemontay
Joined: 07 Jun 2012
Total Posts: 1527
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
catnip6362 is not online. catnip6362
Joined: 23 Nov 2008
Total Posts: 438
19 Jun 2015 12:28 AM
Lol,That's checks out then! Thanks Select!


Report Abuse
Selectivemontay is not online. Selectivemontay
Joined: 07 Jun 2012
Total Posts: 1527
19 Jun 2015 12:29 AM
No problem!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Roblox » All Things ROBLOX
   
 
   
  • 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