What's going on with my function?

I have a server script that calls a function inside a modulescript, but it’s acting very strange. When I call the function, it’s like it throws the first parameter away. This issue is solved by adding a random useless parameter before the parameters I need, but I’d rather not do that unless I understand why it’s throwing the first parameter away in the first place. What might be causing this? (If this is unclear in any way, let me know)

Are you calling it with a colon when it should be called with a dot , you may be passing the self param when it is not needed. Can you post the function header inside of the module, and the place where your calling the function.


here is the function header (inside the modulescript):

function PlayerStatManager:GetStat(player,statName)

and here is where it is called (inside the server script):

local lvl = dataModule.GetStat("howdy!",player,"Level")

In the function header if your not using the self keyword then you should just have:

function PlayerStatManager.GetStat(player,statName)

But if you are using then when your calling the function you need to use the colon:

local lvl = dataModule:GetStat("howdy!",player,"Level")

The colon operator is typically only use for instances of a class, you can read more about it here:Functions | Documentation - Roblox Creator Hub

Inside the modulescript, change it to function PlayerStatManager.GetStat(player,statName) and I think that will work. Edit: @cjjdawg already said this

Thanks for all the help! Sorry for replying so late, my brain basically got fried and I had to quit for the day. Your suggestion seems to work, but I don’t quite understand why. Could you explain in detail why my code was broken and what that change did?