Any idea why this script wouldn't work?

I basically have a localscript in StarterGui that handles remote events passed to the client. It detects all other remote event functions but this one:
function fadesound()
local TweenService = game:GetService("TweenService")
local song = game.Workspace:FindFirstChild("Sound")
TweenService:Create(song,TweenInfo.new(1),{Volume = 0}):Play()
end
game.ReplicatedStorage.RemoteEvent2.OnClientEvent:Connect(fadesound)

Although it’s not needed, here’s my code that fires the remote event (jnside a serverscript):
game.ReplicatedStorage.RemoteEvent2:FireClient(person)

Any idea why it wouldn’t work? Two things to note is that “person” does exist and it’s the player. The second thing to note is that the same local script originally LOCALLY creates the same sound this remote event needs to fade.

Try putting print() in the start of the fadesound function to make sure the remote event is working. If it doesn’t print anything, it’s a problem with the remote event.

Sure, I’ll update you if it works or not in 5ish minutes.

why do you have local TweenService = game:GetService("TweenService") inside the function? you don’t have to call it every time the event fires so maybe put it outside lol (just letting you know)

Good idea, I’ll make that change.

It actually did print something which means the remote event was called. Something’s wrong with the actual script then.

did you check if local song exists?

Hold on, I’ll quickly test that.

Yes, i made a script that prints “song here” if local song ~= nil and it worked, however it didn’t make the song fade out. there’s likely something wrong with the tween

hey, so is song already playing when you join the game?

might wanna add a print after the tween plays to check if it actually played or not

No, song starts playing after around 1 minute into the game. One thing to note is that there’s no sounds in workspace beforehand and all sounds are created through script. I’ll check that.

send a picture of workspace in the explorer, please

Actually I believe I found the issue. There’s two audios in the first minute of the game that are never destroyed. The script likely fades these audios because one still doesn’t end when the function is called (the audio only just fades). Thanks for your help, if you didn’t comment that I likely wouldn’t check workspace until hours later.

2 Likes

Everything seemed to work fine when I tested it so check your game if you have multiple instances named ‘Sound’ or you if you have another script adjusting the volume.

1 Like

Wish I could mark 2 things as solutions. Your reply perfectly sums up my issue. Thank you.