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?