So, I’ve seen lately some people either use RemoteEvents to update text/clientsided things from values and or calls from the server. And some decide to go for the same method of using .Changed on values stored inside ReplicatedStorage or something similar.
Which one would be more efficient/better for performance?
I wouldn’t worry about performance or efficiency but if the values are accessible to the client then there is no point in using a remote event. You have to cross the client <-> server boundary just to update some text and it takes time. Latency is the issue with this. Not performance/efficiency. If the client can access the value then let them listen for when the value changes to update their text labels.
It all depends on the situation. For example, if you are tracking the player’s leaderstats and you want to display the value on a gui you should use .Changed since it’ll constantly update every time their values get changed. However, if you want something to run from the client to the server or vice versa a remote event is the only thing you can use.
But if the server was the one updating the values to the ReplicatedStorage, which of course replicates to the clients. Would It just be better to cut inbetween and use remote events instead? Or will remote events cause more latency then .Changed? Though I feel like .Changed would have more latency due to the fact that it needs to first, on the server, change value, replicate, then .Changed fires, then changes text rather then remote event fires then change text.
What if its a value that changes every second or so from the server but small string/text changes and thats it? Basically for example a minigame type of message ontop?
I was thinking about this for a little white because of seeing this, which was an example for another module however, I think it still somewhat applies?
local function callRemote(value)
ReplicatedStorage.CoinAmount:FireClient(player, value) -- fires every time coin amount changes?
end
Though on secondhand, it might be a good idea to just stick with .Changed instead?
Can you explain why you would need to fire a remote event every time their coin value changes? Also, what I’m hearing is that you want to display a message on top of the player’s screen during the minigame once a certain action is met. I would use a remote event for that.
I was looking at the example code for Datastore2 which led to this question but I guess you would fire it to update the values for the clients to see how much they have?
Oh I didn’t see the Datastore2 part. Yeah you should continue to do remoteevents since the server is controlling the transactions through this script. That means the only way to update the values will be through a remoteevent that allows the server to tell the client to update the player’s coin value.
If your question is if it’s a good idea to use .Changed on values in ReplicatedStorage in order to keep DataStore’s up-to-date, no, it’s not a good idea. You’ll exceed the maximum number of calls allowed for datastores extremely quickly.
Data storage is a huge topic with many methods of accomplishing the same thing, but for your topic, in general you’d be better off only saving based on an autosave (maybe around 1 minute), and anytime a player leaves the game.
I don’t believe its actually required to use remote events in this case since you could just create a value in replicated storage for the client to read from. Even if the client changes the value, it won’t affect the server in any way since they have the actual value?
TL:DR, The remote event is just to send the value to the client to read and thats about it?
@ImFarley
I’m questioning on if I should use which one for which occasian. Two issues are for minigame messages and datastore. Should I use .Changed for Minigame Messages and Remote Events for Datastore (i wont update datastore every second or so of course) or just .Changed for both of them?