Need help fixing my script

Hi everyone, I made this script that turns on/off musics and another one for SFX (they are the same but they just disable different sounds.) Somehow, the music one works fine although the GFX one doesn’t work at all. I didn’t change anything and both scripts are almost the same. The sounds for music is located in the workspace whereas the one for SFX is located in the StarterGui. This is probably an easy fix but I can’t seem to find the error. It has to do something with locating the sound probably. Here are the codes for both ones:
The SFX one:

local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local playerGui = plr:WaitForChild('PlayerGui')

local notification = playerGui.StatsResetConfirmation.Frame.Notification
local button = script.Parent

local SFXon = true

script.Parent.MouseButton1Click:Connect(function()
	if SFXon == true then
		script.Parent:TweenSize(UDim2.new(0.125, 0, 0.034, 0), "In", "Linear", 0.05)
		wait(0.051)
		button.TextButton_Roundify_12px.ImageColor3 = Color3.new(255,0,0)
		button.Text = "OFF"
		notification.Volume = 0
		script.Parent:TweenSize(UDim2.new(0.165,0,0.073,0), "Out", "Linear", 0.05)
		wait(0.15)
		SFXon = false
	elseif SFXon == false then
		script.Parent:TweenSize(UDim2.new(0.125, 0, 0.034, 0), "In", "Linear", 0.05)
		wait(0.051)
		button.TextButton_Roundify_12px.ImageColor3 = Color3.new(0,255,0)
		button.Text = "ON"
		notification.Volume = 5
		script.Parent:TweenSize(UDim2.new(0.165,0,0.073,0), "Out", "Linear", 0.05)
		wait(0.15)
		SFXon = true
	end	
end)

Music one:

local music = game.Workspace.Other.Music.Sound
local button = script.Parent

local MusicOn = true

script.Parent.MouseButton1Click:Connect(function()
	if MusicOn == true then
		script.Parent:TweenSize(UDim2.new(0.125, 0, 0.034, 0), "In", "Linear", 0.05)
		wait(0.051)
		button.TextButton_Roundify_12px.ImageColor3 = Color3.new(255,0,0)
		button.Text = "OFF"
		music:Pause()
		script.Parent:TweenSize(UDim2.new(0.165,0,0.073,0), "Out", "Linear", 0.05)
		wait(0.15)
		MusicOn = false
	elseif MusicOn == false then
		script.Parent:TweenSize(UDim2.new(0.125, 0, 0.034, 0), "In", "Linear", 0.05)
		wait(0.051)
		button.TextButton_Roundify_12px.ImageColor3 = Color3.new(0,255,0)
		button.Text = "ON"
		music:Play()
		script.Parent:TweenSize(UDim2.new(0.165,0,0.073,0), "Out", "Linear", 0.05)
		wait(0.15)
		MusicOn = true
	end
end)
1 Like