I need help with printing this off a module

Hello, I need help printing this from a module!
What I want to print from the module: "Hello Friend, How Are You Doing?

Script (ServerScriptService)

local NpcChat = require(game:GetService("ReplicatedStorage").NpcChat)

print(NpcChat[1][1])

Module (ReplicatedStorage)

local module = {
	
	-- "Text", Color3(RGB), enum.Font
	"Test" == {"Hello Friend, How Are You Doing?", Color3.fromRGB(206, 206, 206), Enum.Font.ArialBold}
	
}

return module

I believe this would work:

local NpcChat = require(game:GetService("ReplicatedStorage").NpcChat)
print(NpcChat["Test"][1])
local color  = NpcChat["Test"][2]
local font = NpcChat["Test"][3]
print(color)
print(font)

I’m still getting an error like:

Why are you using == in the module script? Those are for comparing not for setting a value. You also might want to use waitforchild so that it has time to load in.
Server

local NpcChat = require(game:GetService("ReplicatedStorage"):WaitForChild("NpcChat"))
print(NpcChat["Test"][1])

Module


local module = {
	
	-- "Text", Color3(RGB), enum.Font
	"Test" = {"Hello Friend, How Are You Doing?", Color3.fromRGB(206, 206, 206), Enum.Font.ArialBold}
	
}

return module

It’s working, but how could I do this automatically?

example:

[“This is a test”] = “Hello”
[“This is also a test”] = “Goodbye”

Try this:

Module


local module = {
	"Speech1" = {"Hello Friend, How Are You Doing?", Color3.fromRGB(206, 206, 206), Enum.Font.ArialBold}
    "Speech2" = {"Nice to see you again?", Color3.fromRGB(206, 206, 206), Enum.Font.ArialBold}
    "Speech3" = {"Bye friend cya?", Color3.fromRGB(206, 206, 206), Enum.Font.ArialBold}
	
}

return module

Server

--in the server you have a few options for what you can do

--Option 1:
local NpcChat = require(game:GetService("ReplicatedStorage"):WaitForChild("NpcChat")
for i, v in pairs(NpcChat) do
       print(v[1])
       print(v[2)
end

-- Option 2
local NpcChat = require(game:GetService("ReplicatedStorage"):WaitForChild("NpcChat")
local chatnumber = 1

local function chat()
        print(NpcChat["Speech"..chatnumber][1])
        wait(0.3)
        chatnumber += 1
end

chat()
wait(1)
chat()

Okay, so the problem was that I overlooking it. The fix was to remove the " [“Test”] = "

The module now looks like:

local module = {

	-- "Text", Color3(RGB), enum.Font
	{"Hello Friend, How Are You Doing?", Color3.fromRGB(206, 206, 206), Enum.Font.ArialBold}

}

return module
1 Like