Module Scripts function definition

image

Which should I use? And why? How do they differ (if they do)?

1 Like

I may be wrong, but I am pretty sure that’s just preference.

2 Likes

Both do the same thing, it’s just “Syntax sugar” made to make code more pleasant to read for some people.

2 Likes

Its all based on preference but I would advise you to use the second method because its more syntactically pleasing.

And the second method allows you to use the colon : instead of the period ., which allows you to make use of the keyword self to reference the module rather than referencing it by name.

And yes, I’m aware you can achieve the same thing using:

Module.Spawn = function(self, ...)

end

Module:Spawn()

But imo the below one is much more better:

function Module:Spawn()

end

Module:Spawn()
1 Like

thank you, I was stressing that I may be doing something wrong

thank you for clearing this up

since it is all preference, I’d stick with the first one; thank you for clearing it up for me

1 Like

But as you progress further almost always you will use the second method but hey thats jus an opinion, you r free to do wtever you lik :slight_smile:

1 Like

To be honest, they are the same thing. You should use what you prefer. Personally, I like

function function_DICTIONARY.spawn()

It’s easier to see the function command and stuff.

1 Like

why does no one like function_DICTIONARY.spawn =function() it looks so clean tho ):

thank you for your answer as always!

1 Like