String with Module Script Values

Hey, I am trying to do a script that will search in the module script and if the requirement is true. It will create a button and the text on the button will be the name of the table. But, when I try to get the name of the table like below. It returns a table, I need help.

the script:

local M = require(game.ServerScriptService.Module)

for _,v in pairs(M) do
	if M.Requirement == true then
		local B = Instance.new("TextButton")
		B.Parent = game.StarterGui
		B.Text = v
	end
end

the Module:

local Module = {}

Module.Yes = {
	Requirement = true
	Info = "Yes sir"
}

return Module

Hey there, first things first, you have a mistake:

I guess you wanted to write:

if v.Requirement == true then

Also, change the line:

to:

B.Text = v.Info

if you want the Text to be the name of the table, then do:

for k,v in pairs(M) do
    if v.Requirement == true then
	    local B = Instance.new("TextButton")
	    B.Parent = game.StarterGui
	    B.Text = k
    end
end

well I don’t want to info as the text, I want the table’s title. So in that case, “Yes”

I explained in the bottom part of the post, try using this code :slight_smile: !

Oooh I didn’t see! Thank you infinitely, it worked. Thanks again!

1 Like