ModuleScript return issue

This is printing normally inside a script
image

local qweuioqe = ""
for i = 1, 24 do
local a = math.random(1,#jk123ji)
qweuioqe = qweuioqe..jk123ji[a]
end


wait(1)
print(qweuioqe)

But once I try to put that inside a ModuleScript and require() the function I get this:
image
Line: 3

local req = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))

Require (Script):

local req = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))
function req.ui1h3ui212ji3(data)
	print(data)
end

ModuleScript:

local jk123ji = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
local function ui1h3ui212ji3()
local qweuioqe = ""
for i = 1, 24 do
local a = math.random(1,#jk123ji)
qweuioqe = qweuioqe..jk123ji[a]
return qweuioqe
end
end

So basically what I am trying is to receive the information the function should give me.
Information would be a random generated string

I don’t have much experience with ModuleScript yet

2 Likes

Those obfuscation attempts are kinda useless since exploiters can’t see variable names.
The ModuleScript:

local jk123ji = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
	local function ui1h3ui212ji3()
		local qweuioqe = ""
		for i = 1, 24 do
			local a = math.random(1,#jk123ji)
			qweuioqe = qweuioqe..jk123ji[a]
		end
		return qweuioqe
	end
return {
	ui1h3ui212ji3=ui1h3ui212ji3
}

The actual script:

local req = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))
local data = req.ui1h3ui212ji3()

Module scripts return exactly 1 object you place after “return”. It basically has to be anything other than nil. You can return more than 1 value by packing them into an array.

1 Like

It does return but does not generate a new string every time i call it

while wait(1)do
	print(data)
end

will result in

iykevvrfeoiwlgvbryzrihga (x2)
while wait(1) do
    local data = req.ui1h3ui212ji3()
    print(data)
end

You were printing the same object.

Alright haha thanks. I told you im new to modulescripts :sweat_smile:

1 Like