Function in module script not returning

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to return something from a function inside my module script to the server

  2. What is the issue? Include screenshots / videos if possible!
    I am trying to return a table from a function in a module script to the place where it is called from. So first I call a function that is inside the module scriptfrom the server, and then this function calls an other function inside the same module script, and from this function I want to return something to the server script, but it isn’t working

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I searched on the dev forum but couldn’t find an answer, and I have tried to find out what the problem could be, but the only thing I found out so far is that I can’t really return something from the function that I want to.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Really need help on this asap.

2 Likes

can you be more specific on what function you first call, and then that and this; cause its really confusing to refer the functions as this, that; and what do you want to return??

1 Like

I first call Playerinteraction from a server script, and then playerinteraction calls preparestart

If you want to return self which is returned by :PrepareStart(); you can just do return Test; Test being the variable you defined as the output for :PrepareStart

Ye but the thing is that test is nil for some reason

did you add the __index metamethod; also you need to do setmetatable({}, ElevatorManager) instead

2 Likes

I have the metamethod, and self is a table so that doesn’t really change anything.

So it does print but it prints nil? Or no print at all?

It prints nil in the server script, even though it does exist in the module when I print it there.

I believe you want something i asked in the past? Try this

As a first argument of functions, use self, which will be what you expect

Edit: or remove self assignment on 2nd line and try it, not sure if it will work out

that doesnt do anything; since when you do :method(); self is already automatically passed in which is the same as .method(self)

2 Likes