Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why would this script recognize FRAME in test mode but not in play mode?

So I have this broken script I've been trying to fix for months unsuccessfully. I've been troubleshooting and trying to figure out what the problem code is so that I can fix it, and I've narrowed it down to an error I get in the developer console in play mode. This script works perfectly in studio test mode but not in play mode. In Play mode I get an error that says "FRAME is not a valid member of ScreenGui." as if FRAME (which is just a gui frame) isn't in the spot I'm saying it is which can't be true because it works in test mode. Any ideas of what could be causing this? thanks guys!


local BUTTON = script.Parent
local TOOLS = BUTTON.Parent.Parent.FRAME

function onMouseButton1Down(mouse)
	
	TOOLS.Visible = (not TOOLS.Visible)

	
end

BUTTON.MouseButton1Down:connect(onMouseButton1Down)

1 answer

✓ Accepted answer

I believe this could be a simple issue of not using WaitForChild.

local BUTTON = script.Parent
local TOOLS = BUTTON.Parent.Parent:WaitForChild("FRAME")

function onMouseButton1Down(mouse)

    TOOLS.Visible = (not TOOLS.Visible)

end

BUTTON.MouseButton1Down:connect(onMouseButton1Down)

2 comments

0

Thank you SOOOOOO much this is probably what was wrong with all my other scripts too. THANK YOU!

0

No problem :3

This discussion is preserved as it was. New answers, comments, and votes are closed.