|
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 27 Oct 2013 11:49 PM |
| I did just now and no :( with no errors. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 28 Oct 2013 10:44 AM |
| I added that, my bad. What would make that whole sound looped then? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 28 Oct 2013 10:48 AM |
| Is that for the random sound? If so I want the asset sound :/ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|