Game Latency Issue

Am I the only one experiencing game latency issues or do more developers experience this?. We’ve got this really weird problem going on which we discovered in other games like Murder Mystery II and other sword-fighting-based games. For the player that holds the sword, he is close to the player that gets hit but for the player that gets hit, it looks like he’s 10 studs away. (The issue doesn’t appear when you’re not moving the sword registers correctly when standing still) I’ve tried researching it on the Devforum, the internet, and other forums but I can’t really find any solutions. We’ve tested it with a brick on a baseplate and connected a touch function to it. It said the player was 10 studs away from the brick and still got hit. You rather say ‘do not use the touch function’ yeah it is an option but it wouldn’t be any better for the player with the sword since it would look hard to hit because the player is actually further away and it will not register. Anyone knows a solution we’ve really tried hard to find a solution by ourselves.

Gif: https://gyazo.com/f965349696b4c45391cf5c60d3178145

Code:

--// SERVICES \\--
local ServerStorage = game:GetService("ServerStorage")
local playersService = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
------------------
--// MAIN \\--
local KatanaHandler = {}
KatanaHandler.__index = KatanaHandler

function KatanaHandler.new(owner, model, minDamage, maxDamage)
	local gameHandler = require(script.Parent.GameHandler)
	local clientModule = require(replicatedStorage.Modules.ClientModule)
	local newKatana = setmetatable({}, KatanaHandler)
	newKatana.Model = model:Clone()
	newKatana.MinDamage = minDamage
	newKatana.MaxDamage = maxDamage
	newKatana.Owner = owner 
	newKatana.Model.Parent = owner.Character
	local Activated = false
	local HitDeb = false
	local Animations = ServerStorage.CloneObjects.Animations
	local Humanoid = owner.Character.Humanoid
	
	newKatana.Model.Activated:Connect(function()
		if not Activated then
			Activated = true
            replicatedStorage.RemoteEvents.MainFeatures.KatanaEvent:FireClient(newKatana.Owner)
			local connection = newKatana.Model.Hit.Touched:Connect(function(hit)
				local Player = playersService:GetPlayerFromCharacter(hit.Parent)
				local PlayerName = hit.Parent.Name
				local Humanoid = hit.Parent:FindFirstChild("Humanoid")
				if Player and not HitDeb and not clientModule.Wildlings[PlayerName] then
					print((newKatana.Model.Hit.Position - hit.Parent.HumanoidRootPart.Position).Magnitude)
					--if (newKatana.Model.Hit.Position - hit.Parent.HumanoidRootPart.Position).Magnitude <= 3 then
						HitDeb = true
						Humanoid:TakeDamage(math.random(minDamage,maxDamage))
						clientModule.Travelers[Player.Name].killedBy = owner.Name
						wait(0.5)
						HitDeb = false
					--end
				end
			end)
			wait(0.5)
			connection:Disconnect()
			Activated = false
		end
	end)
end

return KatanaHandler
1 Like

hey, here is a much better hitbox module that you can use instead of a touch function. It’s pretty easy to setup and get working, if you have any questions feel free to ask me

1 Like

Sadly this issue affects all games, not just Roblox ones.

This is basically a Ping issue.
Ping is the time between requesting a message from the server and receiving it back.

Let’s say, for example the server is hosted in the United Kingdom. Players from the UK or EU will have a much lower ping (20 - 60ms) compared to players from America (120-250ms).

This means, when the player moves in game - it takes a bit of time to show that movement to other players.
That is why - in the video you show - the ‘runner’ seems to be far away.
But if you look at it from the chaser’s perspective - the runner will be much closer.

The same sort of thing happens typically in Shooter games.
If one player is running to hide behind a wall - sometimes they can get shot when they’re behind the cover, because another shooter can still see them running across.

Its kind of like time-travel. Other players are seeing slightly old information of where you are.
Hard to wrap your head around.

There are some ways to deal with this like GTA does - predicting the player’s future path but it gets messy.
Hope this helps a little.

2 Likes

So what you are saying is that there is no way to fix it actually?

Would there be some way to detect this and take appropriate action?
Such as giving players a warning that their device is processing information slower as to not cause any misconception of hackers?

Proscled and myself with some of our testers looked at other games such as MM2, SFOTH and a baseplate ( empty game we used for the experiment ) using Touched event and it seemed to happen inconsistently with both of us having decent ping and FPS.

The biggest element is that the server would recognize one player as over 9 studs away and still let the touched event fire.

We ran some code ( Example ) which prevented it from giving damage to other players past their distance to the server but on the client it looks like the game is glitching.