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: How do I repeat a script.

Previous Thread :: Next Thread 
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
29 Sep 2013 11:44 PM
Simple I know, just what exactly do I type.


"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
29 Sep 2013 11:48 PM
Maybe repeat: ?

"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
29 Sep 2013 11:52 PM
Depends, if you want to repeat it a certain amount of times, use a for loop. If you want to repeat in infinitely, use a while true do loop, or, if you want to do it for all of the contents of a table, use a for i,v in pairs loop. The roblox wiki has great articles on all of the above.
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
29 Sep 2013 11:54 PM
Oh, if you do use a while true do loop, make sure to add at least a wait(.1) at the end if you don't have a wait in the script to keep down the lag. If you don't add one, it will crash roblox.
Report Abuse
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
30 Sep 2013 12:08 AM
Alright, Thanks.

"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
30 Sep 2013 12:18 AM
Thanks once again. You helped me create this.:

local s = Instance.new("Sound")

while true do
wait(5)

s.Name = "Alert"
s.SoundId = "http://www.roblox.com/asset/?id=130841492"
s.Volume = 1
s.Looped = false
s.archivable = false

s.Parent = game.Workspace

wait(30)

s:play()
end



"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
30 Sep 2013 12:23 AM
:D
Tip:
s.Volume = 1
s.Looped = false
Don't matter if you want them to be those values, it defaults to those.
Report Abuse
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
30 Sep 2013 12:37 AM
Alright, mind if I ask you one more thing?

"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
30 Sep 2013 12:41 AM
Go ahead.
Report Abuse
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
30 Sep 2013 12:42 AM
I don't know how hard it is for you to answer, but lets say with that script I had set. Instead of wait, how could I have a random math value. Hopefully you understand what I mean. I'm not much of a scripter.


"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
30 Sep 2013 12:44 AM
You could use this, just change the two values:
wait(math.random(minvalue,maxvalue))
Report Abuse
gtakid2477 is not online. gtakid2477
Joined: 06 Feb 2009
Total Posts: 207
30 Sep 2013 12:49 AM
Alright, thank you so much. If you want, I'll give you a copy of what this is making.


"Do you enjoy heaps of dancing and frivolous diversions, cause I do, Sir or Ma'am."
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
30 Sep 2013 12:50 AM
So, if yo wanted to play that sound at a random interval 10 - 30 secs, this would be the best way, so you don't keep creating infinite sounds. :) :

local s = Instance.new("Sound")
s.Name = "Alert"
s.SoundId = "http://www.roblox.com/asset/?id=130841492"
s.Parent = game.Workspace

while wait(math.random(10,30))do
s:play()
end

That should work, adding the wait in place of the true also makes it wait, it may be a bit hard to understand though.
Report Abuse
mostwanted1 is not online. mostwanted1
Joined: 21 Dec 2010
Total Posts: 511
30 Sep 2013 12:52 AM
I'm good, thanks though. :P I'm just here to help people who want to make things.
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