Frame is invisible when spawning it in via script

Alright,so for some odd reason when spawning a frame in through the script it’s just invisible and if I manually create it it’s visible.Am I missing something?

	local main = Instance.new("Frame")
	main.Name = "Main"
	main.Size = UDim2.new(.5,0,.5,0)
	main.Position = UDim2.new(.5,main.AbsolutePosition.X / 2,.5,main.AbsolutePosition.Y / 2)
	main.AnchorPoint = Vector2.new(.5,.5)
	main.Visible = true
	main.Parent = screengui
	

image

Does the parent have ClipsDescendant on? Are there any skeptical properties (such as BackgroundTransparency is set to 1) on the new one?

image
Parent is basically just a screengui.No,there aren’t any skeptical properties

Maybe in the ScreenGui, .enabled is false or something is causing it to be hidden.

I checked that several times,it is enabled

Seems like Frame would only appear if I would to spawn it directly from ScreenGui.

Can we see like, the entire GUI and it’s paths?

When playtesting: image

Before playtesting: image

In script: image

That’s because you have to set the parent to the player’s gui, not the StarterGui.
The StarterGui is just the template of what the player will have as gui. It copies it over to the player and changes the name to PlayerGui. If u want to edit the Gui, u have to do it with the PlayerGui and not the StarterGui

do

game.Players.PlayerAdded:Connect(function(player))
 local playergui = player.PlayerGui
local main = Instance.new("Frame")
main.Name = "Main"
main.Size = Udim2.new(.5,0,.5,0)
main.Position = Udim2.new(.5,main.AbsolutePosition.X / 2,.5,main.AbsolutePosition.Y / 2)
main.AnchorPoint = Vector2.new(.5,.5)
main.BackgroundTransparency = 0
main.Visible = true
main.Parent  = playergui
end)
2 Likes

Thank you!

(limit limit limit)

3 Likes