Roll function not working because of lag?

Hi there!

Recently, I have begun work on a souls-like experience. One of the features I have added is a roll, complete with i-frames (invincibility frames). However, I began to wonder if the i-frames will still work if the player has bad wifi.

The way I have it set up is that every time the player wants to roll, they send a remote event to the server, which then, upon receiving it, gives the player a force-field for the duration of the roll animation.

I’m worried that if the player has enough lag, the remote event won’t fire in time for the player to properly receive their i-frames. When dealing with slit second responses, I’m worried this could be a major problem for some unfortunate players.

Is there anything I can do to resolve this issue?

The server script

-- Get roblox services
local Debris = game:GetService("Debris")

-- Get the remote event
local Replicated_Storage = game:GetService("ReplicatedStorage")
local Roll_Event = Replicated_Storage:WaitForChild("Remote_Events").Roll_Events.Request_Roll

Roll_Event.OnServerEvent:Connect(function(Player, Time_to_roll)
	local Forcefield = Instance.new("ForceField", Player.Character)
	Forcefield.Visible = false
	Debris:AddItem(Forcefield, Time_to_roll)
end)

1 Like

If you don’t have PVP you could move damage calculations to client side. This is a super easy to exploit method, hackers would easily become invincible. Another method would be to track damage-at-time, when a roll event is recieved check if the play was damaged in the last player:GetNetworkPing() seconds and undo it.

If you do have PVP it’s probably better to keep your system as is so players with good internet have a better time playing, rather than players with bad internet being randomly invincible when attacked.

Could you elaborate on moving damage to the client?

Depends on your scripts. Generally speaking I mean to move humanoid:TakeDamage calls into local scripts, referring to the local player’s humanoid.