Remote function always returning nil

Here the client side is, please ignore most of these function’s.

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

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

local field = {} ; playerStorage = {} ; self = setmetatable({},field) ; field.__index = field 
local Services = require(script.Parent.Parent.Services)
local FunctionStorage = game:GetService("ReplicatedStorage"):WaitForChild("FunctionStorage")
local player = game.Players.LocalPlayer

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

function field:Convert(number)
	local days = math.floor(number / (60 * 60 * 24)) % 7
	local hours = math.floor(number / (60 * 60)) % 24
	local minutes = math.floor(number / 60) % 60
	local seconds = number % 60

	local output = ""

	if days > 0 then
		output = output .. days .. "d "
	end

	if hours > 0 then
		output = output .. hours .. "h "
	end

	if minutes > 0 then
		output = output .. minutes .. "m "
	end

	output = output .. seconds .. "s"

	return output
end


function field:GetInfoAsync()
	self["Services"] =  require(script.Parent.Parent.Services)

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

	task.wait()

	if self["Stats"] == nil then
		warn("Stats | Nil ", self["Stats"])
		task.wait(0.8)
		if self["Stats"] == nil then
			field:GetInfoAsync()
		end
	end
	
	task.wait()

	self["UI"] = script.Parent.Parent.Parent

	warn(self["Stats"])

	self["UI"].Panel.Pages.Home.Stats.Likes.TextLabel.Text = self["Stats"].Likes
	self["UI"].Panel.Pages.Home.Stats.Players.TextLabel.Text = self["Stats"].Visits
	self["UI"].Panel.Pages.Home.Stats.Uptime.TextLabel.Text = field:Convert(math.floor(workspace.DistributedGameTime))

	task.delay(1,function()
		self:GetInfoAsync()
	end)
end

function field:GlobalChat()
	local GlobalChatService = Services.GlobalChatService
	self["UI"] = script.Parent.Parent.Parent

	self["UI"].Panel.Pages.Home.GlobalChat.Frame.Send.MouseButton1Click:Connect(function()
		if playerStorage[player.UserId].db then if playerStorage[player.UserId].db == true then return end end

		playerStorage[player.UserId].db = true
		warn(self["UI"].Panel.Pages.Home.GlobalChat.Frame.TextBox.Text)
		GlobalChatService:filter(self["UI"].Panel.Pages.Home.GlobalChat.Frame.TextBox.Text,player)	
		task.delay(3,function()
			playerStorage[player.UserId].db = false
		end)			
	end)
end

function field:AdminList()
	local Admins = 	FunctionStorage:FindFirstChild("Request"):InvokeServer({["Dict"] = "Admins"})

	task.wait(.7)
	if Admins == nil then 
		warn("Admins is nil :()")
		task.wait(.8)
		field:AdminList()
	end

	self["UI"] = script.Parent.Parent.Parent

	local Administrators = self["UI"].Panel.Pages.Home.Administrators

	for _,admin in pairs(Admins) do
		local ranks = require(script.Parent.Parent.Parent.Parent.Parent.Ranks)
		if not ranks[admin.Rank] then continue end

		local Clone = Administrators.ScrollingFrame.Template:Clone()

		pcall(function()
			Clone.ImageLabel.Image = game:GetService("Players"):GetUserThumbnailAsync(admin.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size352x352)
		end)			

		Clone.TextLabel.Text = admin.Rank
		Clone.You.Text = admin.Username

		Clone.Parent = Administrators.ScrollingFrame
		Clone.Visible = true

		-- Add admin information (join date,name,description,e.c.t)

	end
end

function field:AdminInformationList()
	local Admins = 	FunctionStorage:FindFirstChild("Request"):InvokeServer({["Dict"] = "Admins"})


	self["UI"] = script.Parent.Parent.Parent
	local AdminInfo = self["UI"].Panel.Pages.Home.AdminInfo

	for _,admin in pairs(Admins) do
		local ranks = require(script.Parent.Parent.Parent.Parent.Parent.Ranks)
		if not ranks[admin.Rank] then continue end

		local Clone = AdminInfo.ScrollingFrame.Template:Clone()
		pcall(function()
			Clone.ImageLabel.Image = game:GetService("Players"):GetUserThumbnailAsync(admin.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size352x352)
		end)			

		Clone.Rank.Text = admin.Rank
		Clone:FindFirstChild("Name").Text = admin.Username

		Clone.Parent = AdminInfo.ScrollingFrame
		Clone.Visible = true

		-- Add status

	end
end


function field:Search()
	local Commands = FunctionStorage:FindFirstChild("Request"):InvokeServer({["Dict"] = "Commands"})

	local CustomCommandList = Commands[1]
	local CommandList = Commands[2]

	self["UI"] = script.Parent.Parent.Parent.Parent


	self["UI"].Panel.Pages.Home.SearchBar.MouseButton1Click:Connect(function()
		self["PopUp"] = script.Parent.Parent.UI.PopUps:FindFirstChild("Search"):Clone()

		for _,Command in pairs(CommandList) do
			self["Clone"] = self["PopUp"].Main.Container.Commands.Options.Template:Clone()

			self["Clone"].Title.Text = Command.Name
			self["Clone"].Name = Command.Name
			self["Clone"].Parent = self["PopUp"].Main.Container.Commands.Options
			self["Clone"].Visible = true
			playerStorage[player.UserId].SelectedCommand = nil

			self["Clone"].MouseButton1Click:Connect(function()
				playerStorage[player.UserId].SelectedCommand = self["Clone"].Name
			end)

			self["PopUp"].Main.Container.Creator.Create.MouseButton1Click:Connect(function()
				if playerStorage[player.UserId].SelectedCommand == nil then return end

				local selectedCommand = playerStorage[player.UserId].SelectedCommand

				CommandList[selectedCommand].Function(player)

			end)			

		end
	end)
end

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

field:GetInfoAsync()
field:GlobalChat()	
field:AdminList()
field:AdminInformationList()
field:Search()

return field
1 Like

Didn’t Work

I know, I was just doing that for testing. I don’t know why I do that but I do.

I have attempted that here is the 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")
local ReplicatedStorage = game:getService("ReplicatedStorage")
local FunctionStorage = ReplicatedStorage:WaitForChild("FunctionStorage")

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

function field:getInfo(player, Request)
	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

FunctionStorage.Request.OnserverInvoke = field:getInfo()

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

return field
1 Like

14:29:15.150 ▶ Stats | Nil nil (x4) - Client - Home:46

It seems it’s still returning nil :pensive:

Slight correction, when passing tables to the client, you need to change it tostring(data) if you are iterating through a table, or else it will return something unwanted. I found this out when doing MonsterDevz tutorial on clicker simulator. It causes errors as the way client and servers talk it will automatically change the way the client recieved that information unless you type tostring(data)

Could you send the link to that video? (The one you found this out from if possible.)

I’ve always been able to pass tables normally, unless it’s a metatable

Ah, let me try to send this as a normal table then.

Edit: Didn’t work.

Well it’s not even calling (receiving?) your remote so I wouldn’t expect it to

You do have a point.

Character Limit

aaaaaaaaaaaaaaaaa

I’d say check other scripts to make sure there’s no conflict because I don’t see any major issues with it

1 Like

That is the ONLY script calling that remote function.

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)