"Not a valid member" Situation

I’ve been at it for a few hours now and I need some help.

I’m trying to test out a function where the LocalScript fires a command to play a sound under the same hierarchy and is supposedly doing what it’s programmed to do… in studio mode.

image

  1. The script firing the command
  2. The sound playing in the ‘DialogBox’ parent

I tried testing it in a real server. Everything works perfectly fine the script runs the way it should (both in studio and on a dedicated server) until the ‘play sound’ code is fired. I keep getting this error message and it’s starting to get a little ridiculous.

image

I just want to know why this is happening and what I can do to to overcome this error. Thanks!

image

You could try testing on the studio “Test” tab and see if that helps you debug:

image

script.Parent:WaitForChild(“Confirm”)

try that instead

@STORMGAMESYT7IP It does not work
image

repeat wait() until script.Parent

add that at the start of the script and then try

Same thing happened again ----

Show more of the code. Is the script or its parent being removed at any point during your game?

This is the whole code:

image

Why do you have a wait(3) at the end of a script?

Also you didn’t answer:

I’m guessing that, since this is a “Dialogue Box”, that it gets deleted once the player hits “confirm” or something.

Oh I forgot to show script.Parent.Main.Visible = false

@nicemike40 There is another script that enables the local script and makes the main frame visible when a button is clicked. But it has nothing to do with the error.

@nicemike40 No. Nothing is being removed at any point during the game.

I don’t think using Play() will work in any place other than workspace. Try moving it to workspace and see if it will work

It still does not work.⠀⠀⠀⠀⠀⠀⠀

Localscripts cannot access certain things in workspace the last I checked. Have you tried placing the sound under the local script? Another thing you may want to consider is when you are making the Gui not visible. I’m not entirely sure but this may have an effect on it. Try making it play before the gui closes.

Is “Archivable” enabled on the sound?

Try playing the sound locally with SoundService:PlayLocalSound.

Create a new sound instance, set the Id to your sound Id, then play it with SoundService and then delete the sound after it finishes.

Tell me how it goes!