Remote function always returning nil

Yes, I had this on the server then I noticed that is really stupid so I’m trying to switch it over to the client but this is causing it not to work at all.

Here’s MainModule you will need it :wink: https://create.roblox.com/store/asset/16648425286

I don’t see any reason for why it wouldn’t be working

Well, thanks for trying to help anyways :heart:

What the heck-

Also was that the whole module?

That isn’t the whole module, feel free to look at the code here

Or well, I meant the part on the server with the function

Ah, My mistake there. Here is the full analyticsService code

repeat task.wait() until game:GetService("ReplicatedStorage"):FindFirstChild("FunctionStorage")

---------------------------------- || Variables || ----------------------------------

local field = {} ; self = setmetatable({},field) ; field.__index = field 
local HttpService = game:GetService("HttpService")
local MarketplaceService = game:GetService("MarketplaceService")

---------------------------------- || Methods || ----------------------------------

function field:getInfo()
	local Votes
	local Details
	local Info = MarketplaceService:GetProductInfo(game.PlaceId)


		Votes = HttpService:JSONDecode(HttpService:GetAsync("https://games.roproxy.com/v1/games/"..game.GameId.."/votes"))
		Details = HttpService:JSONDecode(HttpService:GetAsync(`https://games.roproxy.com/v1/games?universeIds={game.GameId}`))

	return {
		["Thumbnail"] = "rbxassetid://".. Info.IconImageAssetId,

		["Name"] = Details.name or "N/A",

		["Description"] = Details.description,

		-- Stats

		["Active"] = Details.playing or "N/A",
		["Visits"] = Details.visits or 0,
		["Favorites"] = Details.favoritedCount or "N/A",


		["Creator"] = Details["creator"],
		["Updated"] = Info.Updated,
		["Created"] = Info.Created,

		-- Votes

		["Likes"] = Votes.upVotes or "N/A",
		["Dislikes"] = Votes.downVotes or "N/A",
	}

end

game:GetService("ReplicatedStorage"):WaitForChild("FunctionStorage"):WaitForChild("Request").OnServerInvoke = function(player,Request)
	warn(player,Request)
	if Request == "Statistics" then
		local Info = field:getInfo()
		print(Info)
		warn("Getting Info!")
		return Info
	end
end

---------------------------------- || RBX Signals || ----------------------------------

return field

If I may ask, why are you doing weird metatable stuff for a static function?

I just like to be able to use : when making functions.

You still can without a metatable

I might be missing it, but 2 things i’d change.

  1. Seperate your function calls and you REALLY need to not code like that…
local ReplicatedStorage = game:getService("ReplicatedStorage")
local FunctionStorage = ReplicatedStorage:WaitForChild("FunctionStorage")
--Create a local function
local function GetInfo(player, Request)
--code
FunctionStorage.Request.OnserverInvoke = GetInfo

2nd, I dont think you are aware of 2 things, number 1 things returned between client and server are automatically switched to a string even if you return a number. You are returning a table and to return a table you need to follow this article:

You can’t just return tables between client and server they have zero knowledge of what was made in that table. But if you insert it into a table and just reutrn that main table you go around the issue, you are returning the table itself as it is defined, and I never have seen that but I am sure it can be done. I would take the much easier route.

2 Likes

Ah, I didn’t know that, well when Phase 2 of this panel comes out I’ll keep that in mind (I’m going to keep it like this for constancy.)

1 Like

I feel like if you are not even getting a print of that first ‘warn’ then its not even calling the function on the server. Are you sure the server and client are both looking at the same remotefunction?

On the server I see you set the path specific …

game:GetService("ReplicatedStorage"):WaitForChild("FunctionStorage"):WaitForChild("Request").OnServerInvoke = function(player,Request)

On the client what path are you using for the remotefunction?

self["Stats"] = FunctionStorage:FindFirstChild("Request"):InvokeServer("Statistics")

where does “FunctionStorage” point to?

1 Like

What do you mean by this?

They are looking at the same remote function.

1 Like

They’re asking how you’ve defined ‘FunctionStorage’ in your local script.

1 Like

In the client code in the first post, you have FunctionStorage:FindFirstChild()…

Where does FunctionStorage point to? Is it a variable holding part of the path?

Ah, I have defined it like this:

local FunctionStorage = game:GetService("ReplicatedStorage"):WaitForChild("FunctionStorage")

Since when did remotes convert everything to strings?

2 Likes

Can you provide the local script?