Module script to create ui not working

hi im trying to make a test sort of script, below I have in a module script, childed to a local script in startercharacter scripts. The frame and textbuttons are all created and exist in PlayerGui, however they all have a size of 0 and position of 0, and even after manually editing them in test mode I am unable to see them. Is there a reason none of the UI would show up? thank you

local menuMaker = {}

local replicatedFirst = game:GetService("ReplicatedFirst")
local starterGui = game:GetService("StarterGui")

local buttonSize = .2

function menuMaker.New(Menu,player) --when a new menu needs to be created,
	local Menu = Menu
	local newMenuBackground= Instance.new("Frame",player.PlayerGui) --creates invisible background halfway down the screen
	print("instance created")
	newMenuBackground.Size = UDim2.new({0,1},{0,.5})
	newMenuBackground.Position = UDim2.new({0,0},{0,.5})
	newMenuBackground.BackgroundTransparency = 1
	newMenuBackground.Active = true
	--newMenuBackground.Parent = player.PlayerGui --sets the parent to startergui, so it shouldn't be added instantaneously
	print("menu created")
	menuMaker.Buttons(Menu,newMenuBackground)
end

function menuMaker.Buttons(Menu,newMenuBackground)
	local numberOfButtons = #Menu:GetChildren()--usefull later on when getting the position
	for i,v in pairs(Menu:GetChildren()) do
		local newButton = Instance.new("TextButton") --creates a new button instance for every string value in the 'Menus' folder
		newButton.Size = UDim2.new({0,.2},{0,.2})
		newButton.Position = UDim2.new({0,(i/numberOfButtons)-(buttonSize/2)},{0,.5}) --sets the position to the index of the button over 
		--the total number, minus half the size of the total button. This makes it so you can have multiple buttons and it will adjust to
		--the proper scale
		newButton.Text = v.Name
		newButton.Parent = newMenuBackground
		
	end
end

return menuMaker

that is not how to set UDim2 values
UDim2.new(0, 0, 0, .5)

dont put them in curly bracket thingies, just put them in numbers

local menuMaker = {}

local replicatedFirst = game:GetService("ReplicatedFirst")
local starterGui = game:GetService("StarterGui")

local buttonSize = .2

function menuMaker.New(Menu,player) --when a new menu needs to be created,
	local Menu = Menu
	local newMenuBackground= Instance.new("Frame",player.PlayerGui) --creates invisible background halfway down the screen
	print("instance created")
	newMenuBackground.Size = UDim2.new(0, 1, 0,.5)
	newMenuBackground.Position = UDim2.new(0, 0, 0, .5)
	newMenuBackground.BackgroundTransparency = 1
	newMenuBackground.Active = true
	--newMenuBackground.Parent = player.PlayerGui --sets the parent to startergui, so it shouldn't be added instantaneously
	print("menu created")
	menuMaker.Buttons(Menu,newMenuBackground)
end

function menuMaker.Buttons(Menu,newMenuBackground)
	local numberOfButtons = #Menu:GetChildren()--usefull later on when getting the position
	for i,v in pairs(Menu:GetChildren()) do
		local newButton = Instance.new("TextButton") --creates a new button instance for every string value in the 'Menus' folder
		newButton.Size = UDim2.new(0, .2, 0, .2)
		newButton.Position = UDim2.new(0, (i/numberOfButtons)-(buttonSize/2), 0,.5) --sets the position to the index of the button over 
		--the total number, minus half the size of the total button. This makes it so you can have multiple buttons and it will adjust to
		--the proper scale
		newButton.Text = v.Name
		newButton.Parent = newMenuBackground

	end
end

return menuMaker

this helped, however the ui still does not show up.
below is a simpler version I am using to test and you can see for yourself, it is just blank

local module = {}
module.__index = module

module.New = function()
	local screen = Instance.new("Frame")
	screen.Size = UDim2.new(.9,0,.9,0)
	screen.Position = UDim2.new(.05,0,.05,0)
	screen.Active = true
	screen.Parent = game.Players.LocalPlayer.PlayerGui
end

return module

it has to be in a screen GUI I think

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.