Another issue within one of my scripts

Hello, recently I got another bug in one of my scripts, and I was wondering if anybody could fix the issue, the script is below.

if game.StarterGui.OofSounds.AllOofSoundsLeft.Oof.Oof.Playing == true then
script.Parent.CurrentSound.Text = "Currently Playing: Oof"
wait(0.5)
script.Parent.CurrentSound.Text = "Currently Playing:"
else
if game.StarterGui.OofSounds.AllOofSoundsLeft.OOF.OOF.Playing == true then
	script.Parent.CurrentSound.Text = "Currently Playing: OOF"
	wait(1.2)
	script.Parent.CurrentSound.Text = "Currently Playing:"
	else
	if game.StarterGui.OofSounds.AllOofSoundsLeft.OofEchoed.OofEchoed.Playing == true then
		script.Parent.CurrentSound.Text = "Currently Playing: Oof (Echoed)"
		wait(2.7)
		script.Parent.CurrentSound.Text = "Currently Playing:"
		else
		if game.StarterGui.OofSounds.AllOofSoundsLeft.LoudOof.LoudOof.Playing == true then
			script.Parent.CurrentSound.Text = "Currently Playing: Loud Oof"
			wait(8.3)
			script.Parent.CurrentSound.Text = "Currently Playing:"
		else
			if game.StarterGui.OofSounds.AllOofSoundsLeft.OofMusic.OofMusic.Playing == true then
				script.Parent.CurrentSound.Text = "Currently Playing: Oof Music"
				wait(204)
				script.Parent.CurrentSound.Text = "Currently Playing:"
			else
				if game.StarterGui.OofSounds.AllOofSoundsLeft.OofAstromania.OofAstromania.Playing == true then
					script.Parent.CurrentSound.Text = "Currently Playing: Oof Astromania"
					wait(67)
					script.Parent.CurrentSound.Text = "Currently Playing:"
				else
					if game.StarterGui.OofSounds.AllOofSoundsLeft.OofLasagna.OofLasagna.Playing == true then
						script.Parent.CurrentSound.Text = "Currently Playing: Oof Lasagna"
						wait(130)
						script.Parent.CurrentSound.Text = "Currently Playing:"
					end
				end
			end
		end
	end
end
end

If anybody manages to fix the issue within my script, well done, and I will then mark your reply as solved.

Can you state what the bug is or what shows in output?

1 Like

There is no output of the error in the console log.

What exactly are you trying to do in your script though?

I’m trying to make it so if you play a sound the text above it will say like “Currently Playing: insert sound here”

The indentions are kind of confusing to me but I do notice that you have an if statement under each of the if statement I don’t know if you can do that or if you can I forgot

Are you talking about putting else and if together?

Hm… Try doing that ‘elseif’.

Nope

if game.StarterGui.OofSounds.AllOofSoundsLeft.Oof.Oof.Playing == true then
script.Parent.CurrentSound.Text = "Currently Playing: Oof"
wait(0.5)
script.Parent.CurrentSound.Text = "Currently Playing:"
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.OOF.OOF.Playing == true then
	script.Parent.CurrentSound.Text = "Currently Playing: OOF"
	wait(1.2)
	script.Parent.CurrentSound.Text = "Currently Playing:"
	elseif
    game.StarterGui.OofSounds.AllOofSoundsLeft.OofEchoed.OofEchoed.Playing == true then
		script.Parent.CurrentSound.Text = "Currently Playing: Oof (Echoed)"
		wait(2.7)
		script.Parent.CurrentSound.Text = "Currently Playing:"
         elseif 
         game.StarterGui.OofSounds.AllOofSoundsLeft.LoudOof.LoudOof.Playing == true then
			script.Parent.CurrentSound.Text = "Currently Playing: Loud Oof"
			wait(8.3)
			script.Parent.CurrentSound.Text = "Currently Playing:"
		elseif
        game.StarterGui.OofSounds.AllOofSoundsLeft.OofMusic.OofMusic.Playing == true then
				script.Parent.CurrentSound.Text = "Currently Playing: Oof Music"
				wait(204)
				script.Parent.CurrentSound.Text = "Currently Playing:"
                 elseif
                 game.StarterGui.OofSounds.AllOofSoundsLeft.OofAstromania.OofAstromania.Playing == true then
					script.Parent.CurrentSound.Text = "Currently Playing: Oof Astromania"
					wait(67)
					script.Parent.CurrentSound.Text = "Currently Playing:"
				elseif
                game.StarterGui.OofSounds.AllOofSoundsLeft.OofLasagna.OofLasagna.Playing == true then
						script.Parent.CurrentSound.Text = "Currently Playing: Oof Lasagna"
						wait(130)
						script.Parent.CurrentSound.Text = "Currently Playing:"
			
                    end)

Change end) to end

end

Tried that, the ) is marked with a red underline under it.
Indicating that it makes an error if you do it.

Yes, remove the ). Does it work?

Already tried, it doesn’t work still.

The problem should be in the first line, when the game starts, everything from StarterGui gets moved to the PlayerGui.

So a way to fixing your problem would be:

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

if PlayerGui:WaitForChild("OofSounds"):WaitForChild("AllOofSoundsLeft")WaitForChild("OOF"):WaitForChild("OOF"):WaitForChild("Playing") == true then

-- REST

And instead of else if, do elseif, and also fix your indents please.

If you wanna test this, this should be a LocalScript, and not a Server Script (Script) as LocalPlayer cannot be accessed on the server.

This change will only replicate to the client, and if you would want it to replicate to all clients, you should use Remote Events.

There are a lot more issues that people above already mentioned.

i see what you are trying to do here, but i highly recommend you do this instead:

local function findPlayingSound()
     for _, v in pairs(game.StarterGui.OofSounds.AllOofSoundsLeft:GetDescendants()) do
          if v:IsA("Sound") and v.IsPlaying then
               return v
          end
     end
end
local firstPlayingSound = findPlayingSound()
script.Parent.CurrentSound.Text = "Currently Playing: " .. firstPlayingSound.Name
wait(firstPlayingSound.TimeLength)
script.Parent.CurrentSound.Text = "Currently Playing:"
1 Like

This?

local PlayerGui = game:GetService(“Players”).LocalPlayer:WaitForChild()

if PlayerGui:WaitForChild(“OofSounds”):WaitForChild(“AllOofSoundsLeft”):WaitForChild(“OOF”):WaitForChild(“OOF”):WaitForChild(“Playing”) == true then

if game.StarterGui.OofSounds.AllOofSoundsLeft.Oof.Oof.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: Oof”
wait(0.5)
script.Parent.CurrentSound.Text = “Currently Playing:”
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.OOF.OOF.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: OOF”
wait(1.2)
script.Parent.CurrentSound.Text = “Currently Playing:”
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.OofEchoed.OofEchoed.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: Oof (Echoed)”
wait(2.7)
script.Parent.CurrentSound.Text = “Currently Playing:”
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.LoudOof.LoudOof.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: Loud Oof”
wait(8.3)
script.Parent.CurrentSound.Text = “Currently Playing:”
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.OofMusic.OofMusic.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: Oof Music”
wait(204)
script.Parent.CurrentSound.Text = “Currently Playing:”
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.OofAstromania.OofAstromania.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: Oof Astromania”
wait(67)
script.Parent.CurrentSound.Text = “Currently Playing:”
elseif
game.StarterGui.OofSounds.AllOofSoundsLeft.OofLasagna.OofLasagna.Playing == true then
script.Parent.CurrentSound.Text = “Currently Playing: Oof Lasagna”
wait(130)
script.Parent.CurrentSound.Text = “Currently Playing:”
end

No, you’re repeating the same error, you cannot do game.StarterGui.path.to.object in-game as everything has been moved from there, replace those if statements with the one I provided.

It… didn’t work, now what do I do

does the output window have any red text related to this script?

No, but also, if you’re trying to find out what’s all in my starter gui explorer, here’s the screenshot:
StarterGuiExplorer1