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 » Scripters
Home Search
 

How would I create a Proximity Sound?

Previous Thread :: Next Thread 
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 08:24 AM
I'm working a new game and I'm trying to create some realism therefore I am wondering how I can create a script that plays a sound only when the player is like 8 studs from them etc.


Thanks, Much Appreciated.
Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 08:40 AM
Something like this...

local effect = script.Effect

while true do
wait ()
p = game.Workspace:GetChildren()
for i = 1,#p do
local g = p[i]:findFirstChild("Torso")
if (g==nil)then return end
if (g.Position - script.Parent.Position).magnitude < 5 then
hum:play()
end
end
end


Isn't it?
Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 08:41 AM
local effect = script.Effect

while true do
wait ()
p = game.Workspace:GetChildren()
for i = 1,#p do
local g = p[i]:findFirstChild("Torso")
if (g==nil)then return end
if (g.Position - script.Parent.Position).magnitude < 5 then
effect:play()
end
end
end


I took it from my Microphone coding, So would that work?
Report Abuse
Vitouliss14 is not online. Vitouliss14
Joined: 18 Mar 2009
Total Posts: 7918
02 Dec 2012 08:44 AM
You could do that or you could place the sound INSIDE of the part and play it from there so that the sound only plays near the part (Not the whole entire world)

And you could possibly lower the sounds volume so they can only hear it when they are close.
Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 08:49 AM
I've adapted the script to the following...

local effect = script.Parent.Effect

while true do
wait ()
p = game.Workspace:GetChildren()
for i = 1,#p do
local g = p[i]:findFirstChild("Torso")
if (g==nil)then return end
if (g.Position - script.Parent.Position).magnitude < 5 then
effect:play()
end
end
end


But... It is not functioning, Any ideas what could be the problem...
Report Abuse
Vitouliss14 is not online. Vitouliss14
Joined: 18 Mar 2009
Total Posts: 7918
02 Dec 2012 08:51 AM
"wait ()"

That should be wait()

After that I don't see any other problem but other then the fact that I don't really like your coding style (Sorry for being such a hipster right there lol)

Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 08:53 AM
As long as it does the job. xD.
Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 08:55 AM
Okay, I've changed that but it still doesn't appear to be functioning...
Report Abuse
Vitouliss14 is not online. Vitouliss14
Joined: 18 Mar 2009
Total Posts: 7918
02 Dec 2012 09:00 AM
If you want to check if a player's torso is near the part you could do each of the following:

local thingy = game:GetService("Players")
for _,b in pairs(thingy:GetChildren()) do
if (b.Position - script.Parent.Position).magnitude < 5 then
--blah

And you might want to put this script in the player's character itself and run a check in it to check if it is near the part.

Sorry for any confusion this might cause.

You might also want to take this to scripting helpers next though.
Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 09:02 AM
Okay, I'll take it to scripting helpers. I mainly posted here originally to see what I basically needed to do.

Report Abuse
Zarteon is not online. Zarteon
Joined: 25 Apr 2011
Total Posts: 2085
02 Dec 2012 09:10 AM
Just like to update you guys. I've managed to fix the script.

Thanks for your contributions.
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
02 Dec 2012 09:26 AM
It's actually pretty simple; the sound should be based off the player's magnitude to the object.

That's what I did on my Soundscape place.

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
02 Dec 2012 09:49 AM
You don't even need a script for this, fewls.

SoundService FTW.
Report Abuse
SN0X is not online. SN0X
Joined: 24 Oct 2011
Total Posts: 7277
02 Dec 2012 03:34 PM
Local sounds: in playergui
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
02 Dec 2012 11:35 PM
@Prehistoric;

Yes; use both scripting and soundservice to create perfect sound.

Oh if ROBLOX made local soundservice and lighting I could make the perfect immersive game!!111!1!!

*ahem* Dynamic Light Adjust *ahem* Dynamic Mumbled Sounds *Ahem* Dynamic Brightness etc.

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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