I while i was typing it out, people were replying so i might say some stuff thats the same
Well, both works the same.
If your trying to keep it simple, go with the first one.
BUT THIS IS A BIG DIFFRENCE
Lets say you make a script like this
local function moveElevator (studs:number)
end
local studsMax = 10
return {
move = function(studs)
moveElevator(studs)
end,
goUp = function()
moveElevator(studsMax)
end,
goDown = function()
moveElevator(0-studsMax)-- 0-varible makes varible negative
end,
}
And, If You use the other way, this is the result
local MoveElevator = {}
local maxStuds = 10
MoveElevator.move = function(studs)
end
-- MoveElevator.move() YOU COULD CALL MOVE HERE
MoveElevator.goUp = function()
MoveElevator.move(maxStuds)
end
MoveElevator.goDown = function()
MoveElevator.move(0-maxStuds)
end
return MoveElevator
The Diffrence, If you call a functinon for a module and don’t return it yet, you could stilll call the function.
In the first way, we needed to create a function for a elevator to move for both module and script
It makes the script Simpler and shorter IF the move function is long
Also, i would recommend doing this:
local MoveElevator = {}
local maxStuds = 10
MoveElevator.move = function(studs)
end
MoveElevator.Finish = function(time)-- IDK if you need this but . . .
end
return {
move = MoveElevator.move,-- CHECK IF THERE IS NO ()
finish = MoveElevator.Finish,-- CHECK IF THERE IS NO ()
goUp = function()
MoveElevator.move(maxStuds)
end,
goDown = function()
MoveElevator.move(0-maxStuds)
end,
}