#How do i fix this script to make audio fade out (tweens)

68 messages · Page 1 of 1 (latest)

noble jacinth
#

Where does "sound" come from

#

When you've defined it as "music"

#

There is nothing inside of goal

#

Ah nvm I see it is defined now

#

But what's the point of making a new sound with instance.new

rustic latch
#

oh

solemn edgeBOT
#

studio** You are now Level 4! **studio

rustic latch
#

i wasnt sure what instance.new does

#

so i'm not supposed to make a new sound instance

#

when i alrdy designated sound?

noble jacinth
#

Nope. There is no need to make a new sound using instance.new when you already have a designated sound

#

Are there any errors from your code?

rustic latch
#

uhm

#

i'm not exactly sure

#

the sound doesnt fade out as intended

#

so probably

#

though i have a whole different script for playing the sound

#

local sound = script.Parent.Parent.MainMenuMusic
script.Parent.MouseButton1Click:Connect(function(clicked)
sound:stop()
end)

#

i have this to stop the sound

noble jacinth
#

Are you trying to make it fade in our out? @rustic latch

rustic latch
#

out

noble jacinth
#

Okay

rustic latch
#

cause i put the script on the play button

#

so when i press it it fades out

#

is the goal

noble jacinth
#

local sound = script.Parent.Parent.MainMenuMusic

local TweenService = game:GetService("TweenService")

sound.Volume = 1
sound:Play()

local goal = {Volume = 0}
local volume = script.Parent.Parent.MainMenuMusic.Volume

local tweenInfo = TweenInfo.new(2)

local tween = TweenService:Create(sound,tweenInfo, goal)

tween:Play()

#

Try this

#

And if it doesn't work tell me if there are any errors

#

@rustic latch

rustic latch
#

and if that doesnt work

#

wait

#

before i do it

#

do i remove the other local script that plays the music

#

or do i keep it

#

oh wait

#

it works now

#

i removed the other script

#

wait i think i need to make the tween work when i click play

#

instead of automatically fading music out when i load in

noble jacinth
#

What do you want it to be tied to

#

Mouse click? ui button? Key press?

rustic latch
#

mouse click

#

cause its all in the "play" button

noble jacinth
#

But is it tied to a button I mean

rustic latch
#

well yeah

#

mouse1

#

click

#

YESSS

#

i made it work

#

local sound = script.Parent.Parent.MainMenuMusic

local TweenService = game:GetService("TweenService")

sound.Volume = 1
sound:Play()

local goal = {Volume = 0}
local volume = script.Parent.Parent.MainMenuMusic.Volume

local tweenInfo = TweenInfo.new(2)

local tween = TweenService:Create(sound,tweenInfo, goal)

script.Parent.MouseButton1Click:Connect(function(clicked)

tween:Play()

end)

noble jacinth
#

Yep

#

Nice

rustic latch
#

tyvm

#

im very new to scripting but i'm slowly but surely learning

noble jacinth
rustic latch
#

i also have a question

#

i wanna make some sort of loading screen because whenever i load in the play/character/settings buttons are barely loaded and then half a second later the font and etc appears and it ruins the look of everything

#

like i want everything to load in before it goes play/etc

#

without ruining my main menu ui

noble jacinth
rustic latch
#

doesn't work

#

i've done everything perfectly there

#

@noble jacinth

#

i think its outdated

#

i checked comments and recent comments say none of it works

#

which is exactly what happens to me

noble jacinth
#

Hmm strange

#

I suggest just looking up yt videos on it