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
 

Re: Fading in and Fading out music? (-Help-)

Previous Thread :: Next Thread 
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
20 Mar 2016 01:09 PM
So what I'm trying to do is make this script have a fading in and fading out effect

I'm most likely going to do this by use Volume=0.1 Volume=0.2 (exc) and then go back down for the fade out

Here's the script that that i use---------------------------


local this = {}


local musicNow = script.song.Value
local songPitch = 1
local songVolume = 1
local player = script.Parent.Parent

function this.Setup()
if player:findFirstChild("SongPlayerData")==nil then
local b = Instance.new("BoolValue")
b.Name = "SongPlayerData"
b.Parent = player
local o = Instance.new("StringValue")
o.Name = "SongPlay"
o.Parent = b
local v = Instance.new("NumberValue")
v.Name = "Volume"
v.Value = songVolume
v.Parent = b
else
songVolume = player.SongPlayerData.Volume.Value
if player.SongPlayerData.SongPlay.Value ~= nil then
local find = script.Music:findFirstChild(player.SongPlayerData.SongPlay.Value)
if find == nil then return end
script.song.Value = find
musicNow = script.song.Value
musicNow.Pitch = songPitch
musicNow.Volume = songVolume
musicNow:Play()
end
end
end

function this.PlaySong(so)
local ss = script.Music:findFirstChild(so)
if ss == nil then return end
if musicNow == ss then return end
if musicNow ~= nil then musicNow:Stop() end
script.song.Value = ss
musicNow = script.song.Value
musicNow.Pitch = songPitch
musicNow.Volume = songVolume
musicNow:Play()
player.SongPlayerData.SongPlay.Value = so
end

function this.StopSong()
if musicNow == nil then return end
musicNow:Stop()
script.song.Value = nil
musicNow = nil
player.SongPlayerData.SongPlay.Value = ""

end

function this.SetPitch(pit)
songPitch = pit
if musicNow == nil then return end
musicNow.Pitch = songPitch
end

function this.SetVolume(vol)
songVolume = vol
if musicNow == nil then return end
musicNow.Volume = songVolume
end

return this


--------------------------------------------------------
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
20 Mar 2016 01:11 PM
I don't understand, you've provided the answer to your own question.

What do you want from us :P
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
20 Mar 2016 01:15 PM
I guess i did answer my own question but when i go to test this script in studio with the changes that are needed it doesn't fade in or fade out and there are no errors once so ever.

Basically i'm just wondering where i would place the Volume=0.1 (up to 1) and then back up in this script (A friend made this one for me but i'd like it to be improved)
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
20 Mar 2016 01:17 PM
You'll need a for loop and the wait function (or some kind of yield).

http://wiki.roblox.com/index.php?title=Function_dump/Functions_specific_to_ROBLOX#Wait
http://wiki.roblox.com/index.php?title=Loops#For
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
20 Mar 2016 01:29 PM
Ok so i'm kinda confused, Would i need something like this?

---------(Fading into music)------
Volume=0.1
wait(0.1)
Volume=0.2
wait(0.1)
Volume=0.3
wait(0.1)
Volume=0.4
--Exc---


And do the same thing for fading out but with the volume values going down from 1?
Report Abuse
superpants2020 is not online. superpants2020
Joined: 10 Feb 2013
Total Posts: 804
20 Mar 2016 01:56 PM
or you can make the music or edit it with ableton or audacity.
Report Abuse
epicface123321177 is not online. epicface123321177
Joined: 23 Jul 2012
Total Posts: 514
20 Mar 2016 02:11 PM
Yeah but i don't got enough robux to do that :P
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