Why is my function printing nil and not the position?

i have a module script and a script but
My function is printing nil

Module script:

self = {}

function self:Play(pos : Vector3)
	print(pos)
end

return self

normal script

local g = require(script.Functions)
g.Play(Vector3.new(2,3,2))

Why does it happen and how can i fix it?

1 Like

You should be doing

g:Play(Vector3.new(2,3,2)

The reason this is happening is that when you call a function which is defined using :, by using ., the self (Different to what you defined self as) parameter is not passed correctly. An alternative solution would be to do g.Play(g, Vector3.new(2,3,2).

(I would recommend against using self as the name of the table in the module script, as it will lead to confusion)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.