Introduction
So, I'm experimenting with FilteringEnabled, and I need some things to replicate to the other players for my vehicles to work properly (Sounds, Motors, stuff like that). I have a local script under the vehicle that detects changes (using the .Changed
event) and sends the values to the server via RemoteEvent
, which sets the values so everyone can see them.
The Problem
Since the server is also setting values that the driver is setting, there's a little jitter between when the client sets values and when the server sets them. This is most noticeable when setting a value quickly and incrementally.
Example
From the client to the server
--"Val" is a value being monitored for changes --"Server" is a folder containing the RemoteEvent Val.Changed:connect(function(p) local newValue=Val[p] Server.RemoteEvent:FireServer(Val,p,newValue) end)
...And the server can now replicate the value(s)
--"Server" is a folder containing the RemoteEvent Server.RemoteEvent.OnFireServer:connect(function(Player,Object,ValueName,Value) Object[ValueName]=Value end)
One way to avoid this is to have the Server use :FireClient()
on all the client except the one controlling the vehicle, but this requires the values to go from one client to the server and then to all the clients. This also means that a new player joining the server won't see the value replications that took place earlier before. I'm trying to avoid doing this, even though it works. I feel like there's is a better way.
Thanks in advance.
And here lies the week link of developing games or server/client relation ship, latency. There is not a good way to avoid it because it takes X amount of time for information to travel to the client and then X amount of time for the client to respond to the server. You also face a problem when some clients react slower than others because of connectivity issues or the speed of the client itself. There sin't a good way to get around this problem because there is nothing much we can do about latency issues.