Hey guys, this broken script has been frustrating me because It used to work perfectly and now it only works in edit play (testing) mode. I can usually figure out what part of the script is messed up if a script isn't working by removing chunks of code and seeing what happens, or by taking other troubleshooting steps, and I did that here. What I can't figure out though, is that it seems that the problem is the "for index, child in pairs(SBUTTONS) do" part of the code... and i can't find anything wrong with it.
Context Info: -This IS a local script -Script is inside a "frameception" (frame inside a frame inside a frame...) -Filtering Enabled is NOT on
Any help or suggestions would be appreciated. Thanks!
local player = game.Players.LocalPlayer
local BUTTON = script.Parent
local FRAME = BUTTON.Parent.Parent.ScrollingFrame2
FRAME.Visible = false
--------------------------------------------------
function onMouseButton1Down(mouse)
local SBUTTONS = BUTTON.Parent.Parent:GetChildren()
local NAME = BUTTON.Name
print("clicked2")
FRAME.Visible = true
for index, child in pairs(SBUTTONS) do
if child.Name ~= NAME and child.Name ~= "SelectBar"
then child.Visible = false
end
end
end
BUTTON.MouseButton1Down:connect(onMouseButton1Down)

8 comments
Error?
Well in play mode when I open up the dev console it doesn't have any errors that I think are relevant
Also, I don't think it is recognizing its being clicked because I put in the "print("clicked2") to test it and it never showed up in the dev console
Well what errors do you have? Try checking the output, I don't think developer console may work as in intended in Play Solo mode, then again I've never tried. The error should look something like game.Players.Player.PlayerGui.Gui.Script:123 ... something in red text with blue text following.
When I'm in studio and I click the test play button the script works perfectly fine, but its only when I play the game normally that it doesn't work. Here is an example of an error that shows up in the Dev console when I'm actually playing the game. ((red) NameFrame is not a valid member of Frame) ((blue) Script 'Players.GWolflover.PlayerGui.CraftGui.Bolt.Craft.TextButton.Cscript' , Line 2)
That is just one of many almost identical errors. The other ones are the same but for the other items in my crafting menu, and I'm not sure if these errors are related to the problem that this post is about but they could be. The scripts these errors are referring to are within Frames that are descendants of the buttons that contain the script that this post is about. Sorry this is so complex, I'
Also, ive looked at these errors extensively and basically they are telling me that a Frame's child that I refer to doesn't exist and Ive quadruple checked and I referred to it exactly right (in Cscript which is the script the errors refer to) so I don't know whats wrong.
Try replacing index with i