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: Can anyone please help me?

Previous Thread :: Next Thread 
BelowMetro is not online. BelowMetro
Joined: 30 May 2010
Total Posts: 3691
13 Jul 2014 08:13 AM
I'm becoming a regular here with these audio problems...

To keep this short and sweet, I have a looped sound play from the StarterGui when a player hits a part. Since this sound is looped, it never goes off but is so short that it needs to be looped a few times.

So, I need a part for a player to touch that will stop the loop.
Here is the current script that plays the loop.

debounce = false

script.Parent.Touched:connect(function(hit)
if not debounce then
debounce = true
if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local sound = script.Parent.Sound:Clone()
sound.Parent = player.PlayerGui
sound:Play()
wait(30)
end
debounce = false
end
end)

I'm also looking for a fade out effect by lowering the volume by one until its zero if possible.
Since this was made for me and my scripting knowledge is nil, I don't know where to begin however changing this to stop sound rather than play it I would imagine is a quick fix. Fading out I would imagine needs an if loop of some kind.

If anyone can help me with this it would be much appreciated, thanks for your time.
Report Abuse
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
13 Jul 2014 09:03 AM
To fade out you can use a for loop, for example:

for i = 0,1,0.1 do
sound.Volume = i
wait()
end
Report Abuse
BelowMetro is not online. BelowMetro
Joined: 30 May 2010
Total Posts: 3691
13 Jul 2014 10:14 AM
@above
Thanks for the loop, much appreciated.

With the other problem, would it be a simple alteration like I thought to stop the sound from playing? Or will I need to create a brand new piece of code?

Also, where exactly would I put the loop? I assume it would need to go somewhere specific?
Report Abuse
BelowMetro is not online. BelowMetro
Joined: 30 May 2010
Total Posts: 3691
13 Jul 2014 11:50 AM
bump
Report Abuse
BelowMetro is not online. BelowMetro
Joined: 30 May 2010
Total Posts: 3691
13 Jul 2014 01:01 PM
bump
Report Abuse
4567777 is not online. 4567777
Joined: 13 Jul 2013
Total Posts: 128
13 Jul 2014 01:12 PM
debounce = false

script.Parent.Touched:connect(function(hit)
if not debounce then
debounce = true
if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local sound = script.Parent.Sound:Clone()
sound.Parent = player.PlayerGui
sound:Play()
Spawn(function()--creates new thread so wait(30) wont be interrupted
wait(3) -- waits 3 seconds, change this to how long you want it to loop
for i = sound.Volume,0,-0.025 do -- loop until 0, removing 0.025 every time
sound.Volume = i -- sets sound volume to i
wait()
end-- end fade out
sound:Stop() -- stops sound after faded
end)
wait(30)
end
debounce = false
end
end)
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
13 Jul 2014 01:14 PM
I didn't look at your code but I have encountered problems with sounds in studio that were not problems when testing online.
Report Abuse
BelowMetro is not online. BelowMetro
Joined: 30 May 2010
Total Posts: 3691
13 Jul 2014 01:34 PM
Thank you 4567777, this isn't the first time you've helped me.

Your code works however does something different to what I'm trying. Your code both activates and fades out the sound, however I need a script that when the part is touched, fades out a sound that is already playing.
Report Abuse
BelowMetro is not online. BelowMetro
Joined: 30 May 2010
Total Posts: 3691
13 Jul 2014 04:03 PM
Bump
Report Abuse
RaverKiller is not online. RaverKiller
Joined: 09 Jul 2014
Total Posts: 219
19 Jul 2014 05:18 AM
You should use something like this:

Part.Touched:connect(function()
-- fade out as I showed earlier
Sound:Stop()
end)
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