Any other efficient ways to make this?

So I’m making a gui where the player can choose options, the only issue is making the text actually display the options they have. Although rather simple and I DID managed to get it working, I don’t like how the code looks. I’m trying to make the text display as specified in a table, each options have numerical name instead of alphabetical name (1, 2, 3, 4) Does anyone have other ways to make this or is this literally the only way?

	local Character = plr.Character
	local Root = Character.PrimaryPart
	local PosDiff = (part.Position - part.Position).Magnitude
	local DarkFrame = plr.PlayerGui:FindFirstChild("DarkFrame")
	Camera.CameraType = Enum.CameraType.Scriptable
	if PosDiff <= 10.6 then
		local newUi = ui:Clone()
		newUi.Name = "Location"
		newUi.Parent = plr.PlayerGui
		newUi["1"].Text = Option[1]
		newUi["2"].Text = Option[2]
		newUi["3"].Text = Option[3]
		newUi["4"].Text = Option[4]
for i = 1, 4 do
newUi[tostring(i)].Text = Option[i]

tostring makes numbers into strings. You can also do vice versa with tonumber.

You loop 4 times and “i” equals the number the loop is on.

Can’t believe it was this simple, thank you!

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