Remote function always returning nil

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

Thanks for the reply, I’m going to try something that I just thought of!

Edit: That didn’t work.

1 Like

I have tried all of these now, they unfortunately did not work :pensive:.

1 Like

Your problem seems to originate from the field:getInfo() callback.
Make sure to wrap some of those in pcalls in case they error/break, so you can replace them with default values such as 0 or N/A.

Additionally, working with HTTP can sometimes fail, for example, if your connection isn’t valid, it might break your entire callback, so have plans in case it does

1 Like

You seem to use Imperative programming over Declarative programming. This makes finding errors super hard. Many here are showing you a declarative programming style. When things get as complex as what you’re doing this is the way to go … It also very much helps with generic programing.

You found a solution while I was researching … my bad.

1 Like

Well there is a bit of a problem, when I call this function nothing prints even if I do it remotely.

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

---------------------------------- || 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 || ----------------------------------

print("Called")

function field:getInfo()
	print("a")
	local succ,err = pcall(function()
		print("19")
		local Info = MarketplaceService:GetProductInfo(game.PlaceId)

		local Votes = HttpService:JSONDecode(HttpService:GetAsync("https://games.roproxy.com/v1/games/"..game.GameId.."/votes"))
		local Details = HttpService:JSONDecode(HttpService:GetAsync(`https://games.roproxy.com/v1/games?universeIds={game.GameId}`))
		print("Line 24")
		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)

	if not succ then
		warn(err)
	else
		warn(succ)
	end
end

FunctionStorage.Request.OnServerInvoke = function(player,Request)
	if Request == "Statistics" then 
		return field:getInfo()
	end
end

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

return field
1 Like

I don’t know what any of those mean :rofl:

1 Like

Returning within a pcall will result in the 2nd tuple becoming the output (if it’s a success of course).

So err will be your value once it finishes successfully. You’ll need to return err at the end of your callback.

1 Like

It means simply defining things up top over adding them as you go.

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

-- over doing it this way ...

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

More of a top down approach.

I mean nothing prints at all