Frame being deleted upon playing

I am currently developing a new user interface for my game, called Global Rails: Revolution, and I have run into a problem that I cannot seem to fix.

image

In the image above, you can see the “SYSTEM_BOOT” script, which hides a few items from the CoreGui and corrects the visibility of multiple UI items, as well as a variety of frames and a configuration folder. The frame in question is the one named “MarketMenu”, which is essentially a confirmation screen that the user will see upon clicking the “Marketplace” button on the title screen.

image

Upon playing the game, the error above is shown in the output window. In the “SYSTEM_BOOT” script, line 34 is supposed to hide the “MarketMenu” frame that was was shown earlier, but according to the error, the frame does not exist. This is most perplexing, as the “SYSTEM_BOOT” script is the only set of code that refers to the “MarketMenu” frame, and it only tells the frame to hide itself.

image

The image above was taken after the game has been played, and as you can see, the “MarketMenu” frame ceases to exist, and this can be seen both in StarterGui and PlayerGui. The question is, what is happening here? I have attempted to use a different name for the frame, such as “ShopMenu”, using a different parent frame, and I have even tried this in an entirely different ScreenGui, without scripts, and it got deleted anyway. Below is the code contained in the “SYSTEM_BOOT” script.

--Variables--
local mainUI = script.Parent --Defines the ScreenGui
local starterGui = game:GetService("StarterGui") --Defines the StarterGui
local missionButtons = mainUI.MainFrameA.DriveMenu.MissionsMenu.RoutesMenu:GetChildren()

--Hides ROBLOX UI elements--
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,false)
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)

--Show and hide UI elements--
mainUI.TopBar.Visible = true
mainUI.TitleScreen.Visible = false
mainUI.TermsOfService.Visible = true
mainUI.MainFrameA.Visible = false
mainUI.MainFrameA.DriveMenu.Visible = false
mainUI.MainFrameA.DriveMenu.FreeDriveMenu.Visible = false
mainUI.MainFrameA.DriveMenu.MissionsMenu.Visible = false
mainUI.MainFrameA.DriveMenu.MissionsMenu.RoutesMenu.CanvasPosition = Vector2.new(0, 0)
mainUI.MainFrameA.DriveMenu.MissionsMenu.PreviewImage.Image = "rbxassetid://5083206255"
mainUI.MainFrameA.DriveMenu.MissionsMenu.PreviewImage.Cover.Visible = true
mainUI.MainFrameA.DriveMenu.MissionsMenu.Description.Default.Visible = true
mainUI.MainFrameA.DriveMenu.MissionsMenu.Description.InternationalFreight.Visible = false
mainUI.MainFrameA.DriveMenu.MissionsMenu.Description.YouForgotTheJuice.Visible = false
mainUI.MainFrameA.DriveMenu.MissionsMenu.Description.AutorackExpedition.Visible = false
mainUI.MainFrameA.DriveMenu.MissionsMenu.Description.LateFreight.Visible = false
mainUI.MainFrameA.DriveMenu.MissionsMenu.Description.ContinueButton.Text = "N/A"
for i, v in pairs(missionButtons) do
	v.BorderColor3 = Color3.new(0.0941176, 0.0941176, 0.0941176)
end
mainUI.MainFrameA.DriveMenu.WarningScreen.Visible = false
mainUI.MainFrameA.ExploreMenu.Visible = false
mainUI.MainFrameB.Visible = false
mainUI.MainFrameB.MarketMenu.Visible = false

--Conditionals--
if mainUI.Configuration.IsGametest.Value == true then
	mainUI.TermsOfService.MainFrame.DescriptionGT.Visible = true
	mainUI.TermsOfService.MainFrame.DescriptionPG.Visible = false
	mainUI.TitleScreen.Background.Image.ExitButton.Visible = true
else
	mainUI.TermsOfService.MainFrame.DescriptionGT.Visible = false
	mainUI.TermsOfService.MainFrame.DescriptionPG.Visible = true
	mainUI.TitleScreen.Background.Image.ExitButton.Visible = false
end

Any and all help is appreciated, thanks!

2 Likes

I’ve had this same problem before, but there is an easy fix. I just skimmed through your code and everything, so I might be totally off here, but add a

WaitForChild
-- or
Wait(1)

it might be that you are calling it too soon, before it has time to load in, giving the error

Edit: Looked through your code more in-dephly, I was totally off. It actually does delete itself :slight_smile:

The issue may be that you’re trying to refer to the frame before the client has actually loaded it, as you do not use WaitForChild()

For a small example on how to fix just two of the lines, here’s how you would make MainFrameB and MarketMenu invisible:

mainUI:WaitForChild("MainFrameB").Visible = false -- This makes the script wait until MainFrameB is loaded, makes it invisible, and then moves to the next line
mainUI.MainFrameB:WaitForChild("MarketMenu").Visible = false -- Note that we don't have to wait for MainFrameB in this line, as we've already waited for it above and thus know it is loaded. We then wait for MarketMenu, and set it to invisible

This should work, otherwise i’m clueless as to what the issue could be.

Just tried it, and instead of giving the same error, it provides this. The frame is still being deleted.

image

Ah okay my bad, I didn’t see the part about it being deleted.

I’ve looked through your code snippet and it seems to me that your issue will be coming from a different script; nothing you’ve wrote into the one you’ve given us seems to destroy the frame, nor does it set any parent to nil

Could you try looking through some of your other scripts that you think / know interact with the frame?

I’ve already looked through the rest of the scripts in the interface, and there is nothing that even refers to the frame at all. The other scripts deal with their own frames, and only reference external ones when it is required that they return to the title screen.

When I remove the portion of the code that refers to the “MarketMenu” frame, as well as “MainFrameB”, the frame in question is still being deleted, and the interface will look like it should upon startup (below).

If this is the case then it makes me wonder if either you’ve hit a bug that needs to be reported to Roblox, or that your place may be bugged; as said, the script above is 100% not deleting it, and if no other script refers to the frame, I’m truly lost.

There should quite literally be no reason the frame is deleting itself, do you have a virus or anything in-game? You can see all scripts in the game by going to the explorer and searching for “Script”, if you haven’t already then go through the scripts and make sure they’re made by you and your team, and there isn’t anything fishy in them.

This is a local RBXL file that I have saved to my computer, and the only thing in it is the interface, with no possible interference from external sources.

Try push it to an actual place and see if that helps? Just taking shots in the dark at this point as I’m unsure of what the problem is.

Upon testing it in a published place, the same error occurs.

Okay, last thing that I think could even remotely work as I had a similar issue last night (Frame with a UI Gradient disappeared despite being there in studio), I fixed it by just deleting the frame and re-making it with a new one. I know you said you tried it in another screengui with no scripts, but did you just reparent it to the screengui or remake it entirely?

I’m not sure if you want to try this, maybe keep a backup in case it becomes worse or you design it in a way you don’t like.

If this doesn’t work, please let me know and I’ll be quiet lol. If that’s the case then I wish you the best of luck in solving it, as I have no more ideas. Honestly sounds like a bug that needs reporting.

I’ve tried that before, and the same thing happened. I honestly have no idea what is going on, as there is no reason for the frame to be deleting itself.

1 Like

UPDATE: After going back into the local file after testing in the published game, the “MarketMenu” frame was nowhere to be seen in Studio. Upon inserting a new frame, there were no errors whatsoever.

1 Like

So, it works fine? If so it may have just been a file issue that sorted itself out

Yes, it works just fine now. It was a strange scenario, but thank you for your help.

Awesome! Glad you got it fixed. Apologies I made a few mistakes and reading and couldn’t really help too much :sweat_smile:

Happy developing.