Fetching data from server sided script to a client sided script.

Hello,

I’d like to state I’m quite new to gmod and don’t have much experience, however, I do have 5 years LUA experience which shouldn’t really help about this. Anyhow, I’m looking for a way to fetch data from a server sided function via a client script. Seems a bit confusing at first but the reason for this is that the data will be fetched through a database meaning I rather not have it client sided, for that matter, I don’t even think that is possible.

Anyhow, I’m just looking for some examples or what I need to achieve this.

Example Serverside


function testFunction()
	local test = {
		{name = "TestName", steamid = "BLANK", value = "5"}
	}

	return test -- The table needs to be sent over to the client script when requested by the clientsided script
end

Example Clientside


local TestTable = testFunction() -- Calls for the table and waiting for a return
for k,v in pairs(TestTable) do
	PlayerList:AddLine(v.name, v.steamid, v.value)
end

any ideas how to communicate or send data between server sided scripts and client sided?

Cheers for the help bud!