So I’m working on making private servers for players to use for testing, or just playing with small-groups of players. Kind of like a Roblox VIP server…but not…makes sense right?
Anyway, doing this I wanted to integrate it with my database so players can have the same server and customize it how they want. So, I would need to get the data from the database to the client so they can change the settings they have saved, or let them know that they don’t have a server and they should totally make one because they’re super cool. (Invoking the Server)
The problem is: I cannot return values from the Database, it works like this:
myDatabase:GetAsync("Private_Servers","Code", function(Success, Value, ServerResponse)
if not Success then
return "DB_ERROR"
elseif Value.Value then -- if there is no value in the DB
return "NO_SERVER"
else
return game.HttpService:JSONDecode(Value.Value.value)
end
end)
I have no idea where those strings (or the table) goes because it doesn’t go to the LocalScript because it famously prints nil
when trying to print the result of the invoke.
I’ve tried a lot of tricks I thought to do, all with no success:
- Setting a local value to the value to return, then return it after the DB function is done.
- Adding the values to a table, then returning the table.
- Setting a StringValue to the return value, then passing the value after the DB function is done.
The only thing I was able to do with some success is firing an event to the client with the data I received, but this seems unsustainable to me, would cause me to get all sorts of confused.
I’m looking for a way to pass values back to the client without having to fire events to the client. If this is the only, please also let me know and I’ll just deal with it.