So currently, I’m working on connecting the UI to the player data table.
The way I have it set up that all manipulation is handled server-sided, and afterwards I was thinking of creating an event that is fired once server stuff containing the table as a parameter. The event is then listened to locally, and local functions run updating the ui.
Are there better ways to handle this?
(Side question, Bindable or Remote for this?)
EDIT: Note that the way I have it right now, each player has his own remote function.
I’m a little confused. First of all, you only need 1 remote event for everyone and you can check what the players username is that fired it. Second, wouldn’t Datastore a better alternative?
PlayerData table is what is saved in DataStore.
I was thinking of having the Event being PlayerData.Event, where I would make use of self in my table methods.
And it would be deleted when player leaves.
Also, is there any limit for the amount of firing?
Since the game is aimed for 50+ players per server and is RPG, so there will be a lot of data sent and received.
You would want to use a RemoteEvent to give the server 100% control in this situation.
When the player data table is finished brewing on the server, use the FireClient function to send it to the client and store that in a variable which you can do whatever you want with like so:
-- Server
local PlayerData = DataHandler:GetData(player) -- your player data table
RemoteEvent:FireClient(player, "Player Data", PlayerData)
-- Client
local PlayerData
RemoteEvent.OnClientEvent:Connect(function(...)
local Args = table.pack(...)
if Args[1] == "Player Data" and type(Args[2]) == "table" then
PlayerData = Args[2]
end
end)