Why is this not working

I am using a Ui Library which works if I just return

return library

However when I try and return the instructions and the library it errors

return library, instructions

That errors and why

local instructions = [[
Just some plain text here sample text if I must say to be completed
]]

ANYONE KNOW WHY THIS IS ERROING PLEASE REPLY MUCH HELP THANKS

1 Like

What exactly is the error? At this point, it is difficult to determine what the root of cause is.

If that’s ment to be a string do

local instructions = "
Just some plain text here sample text if I must say to be completed
"

Sine that really looks like instructions is a string

It works the same way in Lua, just appearing different.

This is called a “literal string” as explained here: Programming in Lua : 2.4

You can’t do a multiline string that way. Using the double brackets is a string literal and allows for any literal interpretation of string characters as well as multi-line strings without escaping.

1 Like

Unfortunately, it is still the same by using [[]], which is a multiline string. The variable you tried to assign will always error because the computer thinks it’s an unfinished string.

THIS IS THE ERROR IM GETTING

image

I guess this is the issue. ModuleScripts are limited to one value return. No more than that. If you really want to send both in one, then you should wrap it in an anonymous table and then use unpack() when required.

Alternatively, you could assign that to a module variable and read the variable from the other script.

It works if you loadstring it though ._.

Also may you show me an example of this?

-- Module
return {a, b}

-- Script
local a, b = unpack(require(Module))

The other alternative is quite obvious. By referencing Module and indexing any variable should work as well, as if it was a table.

these are the instructions

local instructions = [[
class Window [
	Table flags -> default location for values

	Method Section(name)
		@name -> text for the Section

	Method Label(name)
		@name -> text for the label
		
		return -> [
			Method Set(string) -> sets the label text
			label object (Instance)
		]

	Method Toggle(name, options, callback)
		@name -> text for toggle 
		@options -> array
			location (table) -> alternate table to put value in (default = window.flags)
			flag (string) -> index for value (e.g location.farming)
			autoupdate (boolean) -> will set itself depending on flag (default = false)
			updatedelay (number) -> time to wait before checking if the flag has changed. Only works when autoupdate is true (default = 1)
		@callback -> function to call when toggle is changed

		return -> [
			Method Set(number) -> sets toggle value
		]

	Method Slider(name, options, callback)
		@name -> text for slider 
		@options -> array
			location (table) -> alternate table to put value in (default = window.flags)
			flag (string) -> index for value (e.g location.farming)
			autoupdate (boolean) -> will set itself depending on flag (default = false)
			updatedelay (number) -> time to wait before checking if the flag has changed. Only works when autoupdate is true (default = 1)
			precise (boolean) -> wether to show full number or not -- e.g 0, 1 vs 0, 0.1, 0.2, ...
			default (number) -> default slider value
			min, max (number) -> self explanatory
		@callback(value) -> function to call when slider is changed
	
		return -> [
			Method Set(number) -> sets slider value
		]

	Method Dropdown(name, options, callback)
		@name -> text for dropdown 
		@options -> array
			location (table) -> alternate table to put value in (default = window.flags)
			flag (string) -> index for value (e.g location.farming)
			autoupdate (boolean) -> will set itself depending on flag (default = false)
			updatedelay (number) -> time to wait before checking if the flag has changed. Only works when autoupdate is true (default = 1)
			list -> list of objects to display
		@callback(new) -> function to call when dropdown is changed

		return -> [
			Method Refresh(array) -> resets dropdown.list and sets value to first value in array
		]

	Method Button(name, callback)
		@name -> text for button 
		@callback -> function to call when button is clicked

		return -> [
			Method Fire(<void>) -> calls callback
		]

	Method Bind(name, options, callback)
		@name -> text for keybind 
		@options -> array
			location (table)  -> alternate table to put value in (default = window.flags)
			flag (string)     -> index for value (e.g location.farming)
			autoupdate (boolean) -> will set itself depending on flag (default = false)
			updatedelay (number) -> time to wait before checking if the flag has changed. Only works when autoupdate is true (default = 1)
			kbonly (bool)     -> keyboard keys only (no mouse)
			default (EnumItem)    -> default key for bind;

		@callback(key) -> function to call when bind is changed

	Method Box(name, options, callback)
		@name -> text for box 
		@options -> array
			location (table)  -> alternate table to put value in (default = window.flags)
			flag     (string) -> index for value (e.g location.farming)
			autoupdate (boolean) -> will set itself depending on flag (default = false)
			updatedelay (number) -> time to wait before checking if the flag has changed. Only works when autoupdate is true (default = 1)
			type (string) -> if type is "number", box will only accept numbers
			min, max   (number) -> used to define constraints when type is numbers only
			
		@callback(box, new, old, enter) -> function to call when box is changed
			box -> box object;
			new -> new value;
			old -> old value;
			enter -> wether enter was pressed

		returns -> box object (Instance)

	Method SearchBox(name, options, callback)
		@name -> text for searchbox 
		@options -> array
			location (table) -> alternate table to put value in (default = window.flags)
			flag (string) -> index for value (e.g location.farming)
			autoupdate (boolean) -> will set itself depending on flag (default = false)
			updatedelay (number) -> time to wait before checking if the flag has changed. Only works when autoupdate is true (default = 1)
			list -> list of objects to search for
		@callback(new) -> function to call when dropdown is changed

		return -> [
			Function (array) -> resets dropdown.list and sets value to first value in array
		]
]
]]

For a module variable, use library.INSTRUCTIONS = "your string here". Your script can instantly access this variable through Module.INSTRUCTIONS, depending on variable to module.

yes but still thats just meh dpo you get it

Sadly, that’s the limitation of a ModuleScript being unable to return a tuple. Workarounds are about better than magic code(sometimes not). If it gets the job done(without indicating any signs of breaking after the long run), there shouldn’t be an issue.

The purpose of a module is a reusable table that gets initialised once and referred to whenever you require the module. They aren’t created for the purpose of returning a string - as suggested above you should include instructions in your module rather than trying to make them separate.

It’s not about what’s “meh” or not, it’s understanding what a ModuleScript actually is, why it was created, what it’s for, and its limitations.

Modules are not roblox-specific, so if you want more information and why modules are a single table that acts as a namespace for all the variables and functions you want to be accessible, you can Google modules in Lua.