You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
What I would like to achieve is having my client script (from a PlayerGUI frame) send a returned table that has been processed by a module script function to a server script, all through a remote function. -
What is the issue? Include screenshots/videos if possible!
The issue here is that the module script function is correctly processing the values from the instances in the PlayerGUI, however, the module script is returning nil instead of a table from the function.
This table that I need to be correctly sent through the remote function to the server script, but the server script tells me that the “table” returned in the parameter of the remote function is nil.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried to look for solutions on Developer Hub, but the case is either posts don’t give the solution, or are not especially relevant to my problem.
To be honest, I have no idea how to solve this, because I have other module scripts in my project that have functions that return tables, and there is no problem.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so it’s easier for people to help you!
ModuleScript
local assetFilterContent = {}
function assetFilterContent.GetFilter(filterOptions, filterTypes)
local filterOptionTab = filterOptions:GetChildren()
local categoryParam = filterTypes.Category.FilterTypeInt.Value
local sortAggregationParam = filterTypes.SortAggregation.FilterTypeInt.Value
local sortTypeParam = filterTypes.SortType.FilterTypeInt.Value
local subcategoryParam = filterTypes.Subcategory.FilterTypeInt.Value
local creatorTypeParam = filterTypes.Creator.FilterTypeInt.Value
local marketplaceParam = filterTypes.Marketplace.FilterTypeInt.Value
local creatorNameParam = ""
local MinPriceParam = ""
local MaxPriceParam = ""
for i, v in pairs(filterOptionTab) do
if v:IsA("ImageLabel") then
if v:WaitForChild("FilterTypeStr").Value == "CreatorName" then
creatorNameParam = v.TextQuery.ContentText
elseif v.FilterTypeStr.Value == "MinPrice" then
MinPriceParam = v.TextQuery.ContentText
elseif v.FilterTypeStr.Value == "MaxPrice" then
MaxPriceParam = v.TextQuery.ContentText
end
end
end
--1 2 3 4 5 6 7 8
local filterContentTab = {categoryParam, sortAggregationParam, sortTypeParam, subcategoryParam, creatorTypeParam, creatorNameParam, MinPriceParam, MaxPriceParam}
warn(filterContentTab)
return filterContentTab
end
return assetFilterContent
Client Script
local searchBar = script.Parent
local searchBarFrame = searchBar.Parent
local searchButton = searchBarFrame.SearchButton
local getFilterContent = game.ReplicatedStorage.Asset.Services.GetFilterContent
local assetFilterContentModuleScript = game.ReplicatedStorage:WaitForChild("Asset").Scripts.AssetFilterContent
local assetFilterContentModule = require(assetFilterContentModuleScript)
local catalogFrame = searchBarFrame.Parent
local filterFrame = catalogFrame.FilterFrame
function ReturnSearchBarContent()
local filterOptions = filterFrame.FilterOptions
local filterButtons = filterFrame.FilterButtons
local filterTypes = filterButtons.FilterTypes
local searchBarContent = searchBar.ContentText
getFilterContent:InvokeServer(searchBarContent, assetFilterContentModule.GetFilter(filterOptions, filterTypes))
end
searchButton.MouseButton1Click:Connect(function ()
ReturnSearchBarContent()
end)
Server Script
getFilterContent.OnServerInvoke = function(player, searchBarContent, catalogParams)
local playerAssetList = player.PlayerGui.Marketplace.MarketplaceFrame.CatalogFrame.AssetList
--local filteredCatalogApi = FilterCatalogApi(catalogParams)
print(catalogParams)
ClearAssetList(playerAssetList)
--GetMarketplaceAssets(searchBarContent, playerAssetList, filteredCatalogApi)
end
Additional Information:
When I put a warn function in the Module Script Function to display the table in the output, it does display, but for some reason still, it still returns nil. I still do not know what is causing this. All help is appreciated! Thank you!