No matter where I put a 'Sound' named 'Sound' in the 'ScreenGui' named 'ScreenGui', the developer console gives the same error telling me 'Sound' is not a valid member of whatever it's parent may be. Whether it is the folder named 'Volume', or the 'ScreenGui' itself. The script works like a charm in testing mode in Studio. However, when I test the game while monitoring the local scripts via developer console, I am told 'Sound' is not a valid member of whatever it's parent is. Perhaps I am doing something completely silly and I am blind to it, but I would love to see what help anyone can provide. Thanks.
-StarterGui -ScreenGui -Sound (Sound) -Choose (Frame) -ScrollingFrameHR -ScrollingFrameLR -ScrollingFrameMR -Apply (TextButton) -TextBox -TextLabel -TextLabel2 -Volume (Folder) -High (ImageButton) -LocalScript -Low (ImageButton) -LocalScript -Mute(ImageButton) -LocalScript -Anim (Folder)
Below is one of the three local scripts that receive the error. They both use the same reference for audio. These work fine in Studio, not the game itself.
local Button = script.Parent local audio = script.Parent.Parent.Parent.Sound --tried game.StarterGui.ScreenGui.Sound local low = script.Parent.Parent.Low function onClick() audio.Volume = 0.3 low.Visible = true Button.Visible = false end Button.MouseButton1Click:connect(onClick)
Again, I don't know if I am just being absolutely silly and blind, but I got so frustrated.
It could be the sound hasn't loaded when you've clicked your button so that's why the parent wouldn't be valid.
You can fix this by using WaitForChild().
So your code would be as follows:
local Button = script.Parent local audio = script.Parent.Parent.Parent:WaitForChild("Sound") --tried game.StarterGui.ScreenGui.Sound local low = script.Parent.Parent.Low function onClick() audio.Volume = 0.3 low.Visible = true Button.Visible = false end Button.MouseButton1Click:connect(onClick)
This might not be the problem, however usually when something works in studio but not in an actual game environment this is the problem.
Well assuming the script is located in "Apply" the text button then you are using too many parents. Try using script.Parent.Parent.Sound and let me know whether the error still occurs