Remote function always returning nil

Are you sure the script is even calling? Put a print or warn just before you make the call to the server, see if you are even getting that far.

1 Like


at 7:20 he talked about ti and in a previous video he had to fix some other bugs that cause tables to return as not string (even though they are) I might have this backwards and if I do I am sorry about that. But that isn’t the only problem here in this post. Like I said, i’d define a table, then return that table after not return the actualy defenition of the table. This might be just me but if I make a table like that I would call my table “PlayerInfo” or something and return that. I never really seen someone just return the table as the defenition not saying it is impossible. But I never seen meta tables like that so I don’t think I am helping the problem, sorry about the post.

2 Likes

It seems it is being called, so that isn’t the issue.
image

1 Like

The current issue is that the Remote Function isn’t even being picked-up by the server.

2 Likes

Ah looks like I missed that part, let me look into a more as I have seen this before.

1 Like

Okay so I am new to metatables, but have been looking at them before and I am aware that remote functions and tables can sometimes return nil when you haven’t defeined them. Like this post it tells you, you have to define the table. I know it might seem crazy, but it is worth a shot to just do what this post says as it is super similar to your issue returning nil.

As the person states the function when you call it makes the table for you returning that new table the function created.

1 Like

Thanks, let me look into that really quick.

1 Like

I’m having a hard time replicating your issue. I took a look at the module, required LoadPanel, and everything worked fine on my end:

-- Server
require(script.MainModule.LoadPanel)
-- Client
local FunctionStorage = game:GetService("ReplicatedStorage"):WaitForChild("FunctionStorage")

local self = {}

self["Stats"] = FunctionStorage:WaitForChild("Request"):InvokeServer("Statistics")
print(self.Stats)

Output:

Providing a place file with the issue might be helpful. :slightly_smiling_face:

2 Likes

Well at least I know it works for someone :heart:

here’s a game file for you to use.
test.rbxl (586.9 KB)

Unfortunately that still hasn’t worked, I’m going to wait for @ProgrammingRottie to finish what there doing to see if they can find out the issue.

1 Like

Ahh okay, I apoloigze for misunderstanding the issue. I hope they can help!

1 Like

@ProgrammingRottie How is it going? Have you managed to replicated it?

Try restarting Studio or playing it on Roblox, maybe it’ll work then?

1 Like

Unfortunately that did not do the trick.

Edit: Just noticed we have been doing this for 2 hours.

1 Like

I would test it in studio but I’m not home right now

1 Like

I did. Very puzzling. One thing I did notice was the RemoteFunction no longer returned a value (nil) after the admin panel appeared. Another thing, the function returned a value if it was inside ReplicatedStorage prior to testing the game.

Could you send over the game file you currently have? So I can investigate further.

test2.rbxl (586.5 KB)

Thanks, I will have a look at this when I’m back home. (1-2 hours)

Hi, I noticed this and the issue seems really confusing, but I can try helping. I’m not that advanced at scripting, so please read these tips at own risk

  1. Check the field getinfo function : make sure that the field:getInfo() function on the server is actually returning a value, if this function doesnt return anything or there’s an error within the function that prevents it from reaching the return, then nil will be returned by default

  2. Error Handling : Add error handling around the field:getInfo() call (using pcall) to catch any errors and print them to the output, this can help a lot,

  3. Order of scripts : Make sure that the server script setting up the OnServerInvoke function is running before the client tries to invoke the server because if the client runs first then the server function may not be set up in time, which can cause your problem

I dont have any more tips, I hope these can help atleast a little, your issue is fascinating :wink:

2 Likes