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
 

Re: while loop and .chatted

Previous Thread :: Next Thread 
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
17 Sep 2011 05:02 PM
is there a way to run a while loop and have a .chatted event work in the same script?
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
17 Sep 2011 05:15 PM
Coroutines or delay()

http://wiki.roblox.com/index.php/Floodcheck_%28Hates_you%29
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
17 Sep 2011 05:24 PM
so how would i incorporate coroutines into a script like this?
(just an example)

while wait() do
print("St00f")
end

game.Players.Player.Chatted:connect(function(msg)
if msg == "lol" then
print("lol")
end
end)
Report Abuse
theopfor is not online. theopfor
Joined: 08 Feb 2011
Total Posts: 11003
17 Sep 2011 05:28 PM
thanx 4 script

"Death to lazy builders. Remove the CFrame tools. Command bar all the way"~pauljkl
"If it tastes bad, it's probably healthy" -RadioactiveWafflez
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
17 Sep 2011 05:29 PM
I'd rather use delay()

function Loop()
while wait() do
print("St00f")
end
end

game.Players.Player.Chatted:connect(function(msg)
delay(0, Loop())
if msg == "lol" then
print("lol")
end
end)

http://wiki.roblox.com/index.php/Floodcheck_%28Hates_you%29
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
17 Sep 2011 06:09 PM
ah, thanks :D
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
17 Sep 2011 06:17 PM
"delay(0"

WHAT ARE YOU DOING????
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
17 Sep 2011 08:20 PM
delay(0,

is

Spawn(

However, you need to do:

delay(0,Loop) -- no () after Loop

otherwise, you'll call the function in the current thread and never get to anything else (like the error in the delay).
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
17 Sep 2011 08:22 PM
Of course the original script doesn't need that:

game.Players.Player.Chatted:connect(function(msg)
if msg == "lol" then
print("lol")
end
end)

-- put the loop at the end
while wait() do
print("St00f")
end

Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
17 Sep 2011 08:38 PM
thanks for clearing that up :P
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