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
 

I just want some....

Previous Thread :: Next Thread 
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
27 Oct 2013 11:43 PM
Conformation on whether this is correct or not.

## Code ##


----------


Assets = {12312,23123} -- Put each musical ID in here, the numbers I have are fake and will not play anything
for _, asset in ipairs(Assets) do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
asset.Looped = true
wait(0.1)
print("Playing.")
end
Sounds = {130792274;130976109;12222005}
print("Sounds Table loaded")
Players = {}
print("Players Table needs more values")
for _, a in pairs(game.Players:GetPlayers()) do
    table.insert(Players, a.Name)
    print(a.Name)
end

for i = 1, #Sounds do
    wait(10)
    x = Instance.new("Sound", Workspace)
    x.SoundId = "http://www.roblox.com/asset/?id="..Sounds[i]
    x:Play()
    x.Name = "Random sound"
    print(Sounds[i])
end

I literally cannot be bothered to be line numbers in.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Oct 2013 11:45 PM
test it
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
27 Oct 2013 11:49 PM
I did just now and no :( with no errors.
Report Abuse
cheatmaster18 is not online. cheatmaster18
Joined: 29 Oct 2010
Total Posts: 1871
28 Oct 2013 04:32 AM
why do you use "asset.Looped = true" on a number value?

That will only break your script.

Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 10:44 AM
I added that, my bad. What would make that whole sound looped then?
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 10:45 AM
Down where you're going through your sounds, right before you go Sounds[i]:Play(), put in Sounds[i].Looped = true

This is my siggy when I'm at school c:
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 10:46 AM
Oops, my bad, I mean before x[i]:Play(), and x[i].Looped = true. My bad.

This is my siggy when I'm at school c:
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 10:48 AM
Is that for the random sound? If so I want the asset sound :/
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 11:00 AM
It's in your for loop, which means that it will be applied for every sound. The looped means that it will loop that sound, so the sound will never stop.

This is my siggy when I'm at school c:
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 11:02 AM
Okay...
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 11:07 AM
Omg XD I just realized I didn't put the Asset ID in the sound that's in Workspace, so I don't think there is any need to pre load the Sound :/
Report Abuse
CustardCream95 is not online. CustardCream95
Joined: 16 Aug 2012
Total Posts: 579
28 Oct 2013 11:16 AM
Only need one for loop now then; the first will be long commented just in case.

Full script.
------------

game.Workspace.Heartbeat:Play() -- It now has the correct asset id.

-- THE FIRST FOR LOOP TO PRE-LOAD THE SOUND (LONG COMMENTED)
--[[
Assets = {} -- Put each musical ID in here, the numbers I have are fake and will not play anything
for _, asset in ipairs(Assets) do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
asset.Looped = true
wait(0.1)
print("Playing.")
end
--]]

[[ Random Sounds ]]

Sounds = {130792274;130976109;12222005}
print("Sounds Table loaded")

for i = 1, #Sounds do
    wait(10)
    x = Instance.new("Sound", Workspace)
    x.SoundId = "http://www.roblox.com/asset/?id="..Sounds[i]
    x:Play()
    x.Name = "Random sound"
    print("http://www.roblox.com/asset/?id="..Sounds[i])
end

Are there any changes to be made to make it perfect?
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
28 Oct 2013 11:50 AM
Alright, I'm just going to fix this for you. Here ya go:

Assets = {12312,23123} -- Put each musical ID in here, the numbers I have are fake and will not play anything
for _, asset in ipairs(Assets) do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
wait(0.1)
print("Playing.")
end
Sounds = {130792274;130976109;12222005}
print("Sounds Table loaded")
Players = {}
print("Players Table needs more values")
for _, a in pairs(game.Players:GetPlayers()) do
table.insert(Players, a.Name)
print(a.Name)
end

for i = 1, #Sounds do
wait(10)
x = Instance.new("Sound", Workspace)
x.SoundId = "http://www.roblox.com/asset/?id="..Sounds[i]
x.Looped = true
x:Play()
x.Name = "Random sound"
print(Sounds[i])
end

This is my siggy when I'm at school c:
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