Indexing nil when casting a module function

Hello all,
I’ve recently dove into module scripts to learn more about them, and I’ve come across an error I’m unaware of how to fix.

I have a module setup that creates a new projectile, then has a linked function that casts it (shoots it). However, when I cast the projectile it errors with an “Attempt to index nil with ‘Cast’”

Module:

function ball.new(statement)
   local newProj = {}
   newProj.Message = statement

   function newProj:Cast()
      print(self.Message)
   end
end

Server:

local proj = require(game.ServerStorage.Modules.Projectile).new("Hello World!")

RemoteEvent.OnServerEvent:Connect(function(plr)
   proj:Cast()
end

Any help?

This should be in #help-and-feedback:scripting-support

My bad, this is my first dev forum post.
How would I move it there?

You forgot to return the actual object.

Also - You have a constructor of which you’re not calling. This appears to be an improperly written OOP code.

It’s fine. I would help you if only I knew scripting.

I completely forgot you need to return stuff in modules :sweat_smile:

Any suggestions for the constructor? I’m still new to lua classes and modules. Most of my experience is in Python

local obj = class.new()
obj:Cast()