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 » Game Design
Home Search
 

Re: Local Audio help?

Previous Thread :: Next Thread 
vaporwavehighschool is not online. vaporwavehighschool
Joined: 17 Jun 2014
Total Posts: 21
09 Apr 2015 07:07 PM
I've recently added music to a place I'm making, which is good, but now what I want to do is make it so that the music isn't playing globally throughout the entire map, and only plays within a certain area, and when a player moves out of that area, it no longer plays for that player. Is there any way to do that?
Here are links to my script and relevant workspace.
workspace:
https://twitter.com/gorillionbucks/status/586318932228857856
script:
https://twitter.com/gorillionbucks/status/586319241877520385
the first script is the one in question, the second one just makes the block invisible after a few seconds.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 07:09 PM
All you need to do is clone the audio into the player and it will only be heard by that player. This is what I do for my audio.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 07:10 PM
Also, on the side, use audio.TimePosition and audio.TimeLength to detect when audio finishes playing.
Report Abuse
vaporwavehighschool is not online. vaporwavehighschool
Joined: 17 Jun 2014
Total Posts: 21
09 Apr 2015 07:21 PM
I don't have problems with the audio being heard, but I want it only to be heard in a certain area, as I want to put more than one audio track in for different locations.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 07:25 PM
Add an audio to the player when they join

When in a particular area, change the audio ID to the ID you want.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 07:27 PM
This can be achieved simply by a touched event to detect when a player enters an area, or even by using magnitude

http://wiki.roblox.com/index.php?title=Magnitude
Report Abuse
vaporwavehighschool is not online. vaporwavehighschool
Joined: 17 Jun 2014
Total Posts: 21
09 Apr 2015 07:28 PM
How would I go about making the audio ID change in certain areas? I don't know much of roblox scripting.
Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
09 Apr 2015 07:39 PM
this is probably the worst and most simple way of doing this, but...

script in ServerScriptService that adds the audio into the player:

game.Players.PlayerAdded:connect(function(player)
wait(5)
local findAudio=player:FindFirstChild("MasterAudio") --checks if the audio has already been added to the player
if findAudio==nil then
local audio=Instance.new("Sound", player) --creates the audio
audio.Name="MasterAudio"
end
end)


now, this is a script inside an INVISIBLE part, with CANCOLLIDE off (meaning players can walk through it). Anybody inside this part stretched around your area will hear the specific sound.

soundId=1498412 --change to the ID of the sound that will play
db=false
script.Parent.Touched:connect(function(hit)
if db==false then --make sure this script doesn't get activated a ton of times
every touch
db=true --make it so this function doesn't fire again until we're done
local human=hit.Parent:FindFirstChild("Humanoid") --looks for a human
if human then --if the thing that touched was a human...
local player=game.Players:GetPlayerFromCharacter(hit.Parent) --find the player
if player then --if the player exists then
local audio=player:FindFirstChild("MasterAudio") --look for the audio
if audio then --if the audio exists then
audio.SoundId=soundId --change the audio to the audio you want
end
end
end
wait(3) --wait 3 seconds after we're done
db=false --make it so this can activate again
end
end)


This is not the most efficient way but it's simple to understand without scripting knowledge
Report Abuse
vaporwavehighschool is not online. vaporwavehighschool
Joined: 17 Jun 2014
Total Posts: 21
09 Apr 2015 07:50 PM
I can't seem to make a part stretched out over my area, even with CANCOLLIDE off, how would you go about doing that? I also don't know how to make a part invisible, either.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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