Help getting player's choice

So, im making a character creation system and i need to get a player answer by an GUI. I did it but I feel its kinda wrong.

local Gui = script.ScreenGui

local Character = {}

Character.new = function(player:Player)
	local Gui = Gui:Clone()
	local Background = Gui.Background
	local MainFrame = Background.Frame
	Gui.Parent = player.PlayerGui
	
	local Gender = nil
	
	MainFrame.Male.MouseButton1Click:Connect(function()
		Gender = "Male"
		Gui:Destroy()
	end)

	MainFrame.Female.MouseButton1Click:Connect(function()
		Gender = "Female"
		Gui:Destroy()
	end)
	
	repeat task.wait() until Gender ~= nil
	
	print(Gender)
end

return Character

Any suggestions on how to improve?

1 Like

Wrong section to post in.

In the future please use Code Review, if you want ways to “improve”

1 Like

Sorry, its my first post on the forum

How does this function when you try it out in your game? Also use your output window to see if you messed up on any lines of code