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: Player entered audio

Previous Thread :: Next Thread 
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 05:36 PM
So, I'm trying to make it so when a player enters they hear a audio, one only let me hear it, and with some help I got this.

local soundid = "http://www.roblox.com/asset/?id = 140777776"

game.Players.PlayerAdded:connect(function(p)
p:WaitForChild("PlayerGui")
local sound = Instance.new("Sound", p.PlayerGui)
sound.SoundId = soundid
repeat wait() until p.Character
sound:Play()
game:GetService("Debris"):AddItem(sound, 1)
end)

Now, this still doesn't work. Anything I'm doing wrong?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 05:38 PM
You may need to preload the sound asset.
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 05:39 PM
What do you mean?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 05:41 PM
"Usually, content is loaded only when it starts being used. That explains why it often takes a moment for an image to appear in a GUI, or a mesh to appear in a part, or why a sound doesn't play for the first time. All because the asset has not yet finished loading. Preload is used to load this content beforehand, so that it works instantly.


Example: Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=2453543") " - Wiki: http://wiki.roblox.com/index.php/Preload_(Method)
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 05:42 PM
So where should I add it in the script?
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 05:43 PM
Btw, I'm not good at scripting like I can't write my own... But this is where I got this:

http://www.roblox.com/Forum/ShowPost.aspx?PostID=122032851
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 05:59 PM
Before anything else in teh script.
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:01 PM
So this right?

Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=2453543") "
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:05 PM
So I have this in a script in workspace and it still is not working:

Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id = 140777776")
local soundid = "http://www.roblox.com/asset/?id = 140777776"

game.Players.PlayerAdded:connect(function(p)
p:WaitForChild("PlayerGui")
local sound = Instance.new("Sound", p.PlayerGui)
sound.SoundId = soundid
repeat wait() until p.Character
sound:Play()
game:GetService("Debris"):AddItem(sound, 1)
end)

end
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:06 PM
Maybe I should remove the last end?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 06:06 PM
Not sure, then. Sorry man.

Does the Debris service delete it too quickly?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 06:07 PM
Yes, remove that last end
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:08 PM
Not sure exactly.

I thought this was going to be so simple D:
I tried last night on wiki, that didn't work.
I tried something else that someone told me, that did work but only I could hear it for myself, so then some guy helped me with this for about an hour, then you helped me some more and it still isn't work. I've been trying to get this to work for hours, there must be something I'm doing wrong.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 06:09 PM
Try it not in play solo. Play solo doesn't run .PlayerAdded because the player loads before the scripts.
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:13 PM
I know, I've been adding to the script then I save, quit, and then do play game, and it doesn't play any sound.
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:15 PM
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id = 140777776")
local soundid = "http://www.roblox.com/asset/?id = 140777776"

game.Players.PlayerAdded:connect(function(p)
p:WaitForChild("PlayerGui")
local sound = Instance.new("Sound", p.PlayerGui)
sound.SoundId = soundid
repeat wait() until p.Character
sound:Play()
game:GetService("Debris"):AddItem(sound, 1)
end)

end


Maybe where it says sound.SoundId = soundid <-- I change it to the code.
But I tried that earlier, then someone told me I put the link in local SoundID = " "
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 06:15 PM
Huh. That's really odd, then.

I know the pain of spending ages trying to get something so seemingly simple to work.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 06:16 PM
The 'local' doesn't matter for either variable
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:17 PM
Has to be something that I did wrong.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
02 Jan 2014 06:18 PM
Maybe the players character has to be created for local sounds to be heard?
Report Abuse
Lukekneenew is not online. Lukekneenew
Joined: 20 Oct 2009
Total Posts: 746
02 Jan 2014 06:19 PM
I have had trouble with WaitForChild. Instead of p:WaitForChild("PlayerGui"), try:

while p:findFirstChild("PlayerGui") == nil do wait() end
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:22 PM
I now have this:

Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id = 140777776")
local soundid = "http://www.roblox.com/asset/?id = 140777776"

game.Players.PlayerAdded:connect(function(p)
while p:findFirstChild("PlayerGui") == nil do wait() end
local sound = Instance.new("Sound", p.PlayerGui)
sound.SoundId = soundid
repeat wait() until p.Character
sound:Play()
game:GetService("Debris"):AddItem(sound, 1)
end)

end

Note: This is a normal script in workspace.
Report Abuse
Lukekneenew is not online. Lukekneenew
Joined: 20 Oct 2009
Total Posts: 746
02 Jan 2014 06:25 PM
Why do you have that last end?
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:26 PM
No idea Lol. From all the help I got, that was added, I'm going to remove that and see if that makes it work.
Report Abuse
b2856 is not online. b2856
Joined: 22 Sep 2007
Total Posts: 1418
02 Jan 2014 06:28 PM
That last end didn't really do anything, but would the script be messed up if line 3 is completely blank? because it has line 1, 2, 3 is blank, and then 4.
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