How would i call a function from a table of functions?

Suppose I have a code that would return a function from a table whenever a remote function is invoked like this:
Server side:

local function getPlayerStateData(player, _type)
	if _type == "States" then return playerStatesData[player.UserId] end
	if _type == "Moves" then return playerMovesData[player.UserId] end
end

local playerDatas = {
	["States"] = getPlayerStateData
}

game:GetService("ReplicatedStorage).RemoteFunction.OnServerInvoke = function(plr, funcName)
       return playerDatas[funcName]
end

Client side:

print(RFHandler:InvokeServer("States"))

My question is, how’d I call that function on the client side? What do I write to make it return the states type?

Nvm im stupid

RFHandler.OnServerInvoke = function(plr, funcName, _type:string | nil) --Server
	return playerDatas[funcName](plr, _type)
end

print(RFHandler:InvokeServer("States", "States")) --Client

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.