So basically I want to know how to return with a module function, rather than a normal function. It doesn’t seem to operate the same when I try it. I’ve been looking around on the Devforum for a bit, but I can’t find any info.
Basically, I’m trying to do something like this.
-- Variables --
local Module = require(game.ServerStorage.RandoModule)
-- NORMAL FUNCTION --
local function Example()
local test = "Hey, this is how you return, right?"
return test
end
print (Example())
-- ^ This would print 'Hey, this is how you return, right?' . . At least I think it would. --
-- MODULE FUNCTION (PRETEND IT'S THE SAME, BUT IN A MODULE SCRIPT) --
Module.Example()
print (Module.Example()) ???
-- ^^ . . How do I return something like this? Add local behind it? . . It bugs out my script when I try
In fact while ModuleScripts are frequently used to return a single table value they can also be used to return a single value of any type (that includes but is not limited to a function value itself). In Lua, functions are recognised as first class values.
I’m still having some trouble when I try doing this
print(Module.Hitbox())
But I’ll figure something out. It like tries to play the function inside of the print, and ends up with a bunch of errors, since there’s no parameters in there
so i was wondering how to make function call itself idk if i said it right i don’t really know what it suppose to be called its like humanoid when the the character stops walking
local hum = script.Parent:FindFirstChild("Humanoid")
hum.MoveToFinished:Connect(function()
--rest of code
end)