Remote events & client to server

Hello guys, I have a question for a problem that I have had when using remote events to pass client to server. It happens that there will always be a delay between client and server, which means that when fireserver sends a remote event, it takes a long time to be received, So knowing this, I tried to make two variables for the client and server, First the client that will be the fastest, and the other to run the remote event so that it is transferred to the server, What I am trying to do is that it will not happen problems with the overlapping of functions, I mean if a client starts to make a function of a skill, effects and so on, it first do it to the client, and then to the server so that the other players can see it, well with this I want is that the server does not transmit that for me, only the other players, since I already transmitted that in my same client, what can I do for this?

1 Like

If I understand what you’re trying to achieve, you can use Players:GetPlayers to loop through every player in the game and only send a remote to them if they aren’t the one who fired the remote.

Example:
local Players = game:GetService("Players")
RemoteEvent.OnServerEvent:Connect(function(player, ...)
	for _, otherPlayer in ipairs(Players:GetPlayers()) do
		if otherPlayer ~= player then
			RemoteEvent:FireClient(...)
		end
	end
end)
2 Likes

Yes exactly, but how the same functions that are in the script will be cloned to the other clients to observe the same thing, I mean if we are in a game where things can be grabbed, a player for example triggered to grab an apple, then with a remote event those signals are received by the server and those same signals that the server obtained will be delivered to the other clients to observe the other player grabbing that apple.

1 Like

Passing data directly from one client to another is simply not possible. The server will always have to be involved during the process of sending data between clients and this is through the use of RemoteEvents.

You don’t necessarily have to worry about the time taken for a client sending data to the server to be replicated to all of the other clients as it’s all done extremely quickly (~35 milliseconds, which is faster than the average human reaction time). However, you do have to consider server performance. Sending too many remote events or simply having unoptimized server code can affect server latency; which would have a more significant affect in your game than worrying about reducing Client->Server->Client transmission speed.

1 Like

This would depend on how your function works.

Using your example of grabbing an apple, you would just send the info that you are grabbing something, the player, and the apple. Then, just tell everyone that the player grabbed the apple by sending it to the other clients.

If this is a skill which should not change in behaviour (like it would always do the same thing, atmost at different locations), just send what skill it is.

tl:dr simply have whatever that function is ready on all the clients (so that all the clients know what it is) and tell the other clients what function you are calling.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.