How Should I Improve Client-Server Events

Not entirely sure if this topic belonged here, so please correct me and I’ll move it asap.

So I’m creating a fighting game which involves a lot of mechanics and I worry about the “bridge” between the client and the server. Almost all of my game interactions and mechanics are handled by scripts in ServerScriptService with client inputs handled in a localscript via UserInputService, and sent through RemoteEvents. My main issue is that it feels choppy (especially the body velocity demonstrated in the video), and I worry that it will affect gameplay and performance. So is there any way or method to make it “less laggy” without sending too much information from the client to the server? (I’m also worried about exploiters)

Video Link

Dropbox - test.mov - Simplify your life

As you watch the video, you’ll notice visible client-server lag, and especially the body velocity. This is what I’m concerned about.

Script Examples
--// LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local RemoteEvent = ReplicatedStorage.WarriorEvent

UIS.InputBegan:Connect(function(Input,gameProcessedEvent)
	if gameProcessedEvent then return end
	
	if Input.UserInputType == Enum.UserInputType.MouseButton1 then
		RemoteEvent:FireServer("Attack")
	elseif Input.KeyCode == Enum.KeyCode.Q then
		RemoteEvent:FireServer("Q")
	elseif Input.KeyCode == Enum.KeyCode.E then
		RemoteEvent:FireServer("E")
	elseif Input.KeyCode == Enum.KeyCode.R then
		RemoteEvent:FireServer("R")
	end
end)
--// Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.WarriorEvent
local RotatedRegion3 = require(ReplicatedStorage.RotatedRegion3)

RemoteEvent.OnServerEvent:Connect(function(Player,Input)
	if Input == "Attack"then
		-- Code for [Attack] input
	end

	if Input == "Q" then
		-- Code for [Q] input
	end

	if Input == "E" then
		-- Code for [E] input
	end

	if Input == "R" then
		-- Code for [R] input
	end
end)

I think it’s also worth mentioning that I use EgoMoose’s Rotated Region 3 Module to do most of the game interactions.

you need ping backtracking, animation backtracking, client-side hitboxes with server verification, and client replication
simple ez

1 Like

Hmm. I’ve tried several ways to loop around this issue, such as sending the HumanoidRootPart information through the RemoteEvent and reference that in the server, but it still resulted in this delay. Well, it’s as you said, I should transfer over my hitboxes to the client and verify using the server. It’s not my preferred method (as exploiters can easily abuse this), but I do have some ideas that I can set up to prevent those events from happening. Thanks for the suggestion! I’ll come back when things are set up and working again.

Alright. Got most hitboxes and game mechanics on the client side under verification of the server via RemoteFunctions and modules. Again, I’m not particular fond of this method, but it does solve the stated issue. I have some bugs here and there and I still need to figure some things out; but overall, it’s functional to an extent. Again, thank you for the suggestions! It’s smooth cruising from here.