Player lag when playing tag

I’m making a tag game which is currently fully functional, but gameplay is being impacted by lag. It’s not any unusual amounts of lag, I think it’s just the typical latency between the client and the server, but players will be several studs behind another player and it will still register a tag.

I’m wondering if there’s a way to create greater sync between clients so it will look like you’re making physical contact with the player. If you’re trying to tag someone, currently it will look like you’re making contact, but not if someone is trying to tag you.

I’ve heard about Rollback Netcode as a way to try and cut the gap from lag, but I don’t know if that will work for this kind of setup. Any ideas?

1 Like

Sounds client based? Easy to abuse by exploiters?

The scripts that deal with transferring who is “it” are server scripts. The problem is that the player is controlled by the client and player collisions are dealt with by the server.

Ok, just curious how the tag registered. The easiest way I can think of to create the proper illusion is to have a server fired event to the tagged player, targets the player that “tagged” you and run a tween that catches them up at the same time. Sure, it’s a visual cheat, but it will give the illusion that the player “caught” you at the same time they get the “you got tagged” notification. You could technically run this on all the clients so they all “see” the same thing on their screen, this player caught that player and was actually next to them, not several studs behind them as you’ve noted in your testing. This way, it doesn’t break any physics or anti-cheat stuff you are running on the server.

1 Like

Here is the server script that applies when a player tags another player.

game.Players.PlayerAdded:Connect(function(Player)
Player:SetAttribute(“Merked”, false)
Player:SetAttribute(“Playing”, false)
Player:SetAttribute(“PastMenu”, false)
Player.CharacterAdded:Connect(function(Char)
local cr = crown:Clone()
cr.Parent = Char
cr.Position = Char.Head.Position + Vector3.new(0,2,0)
local w = Instance.new(“Weld”)
w.Part0 = Char.Head
w.Part1 = cr
w.Parent = Char.Head
w.C0 = CFrame.new(0,2,0)

	Char.HumanoidRootPart.Touched:Connect(function(touched)
		if touched.Parent:FindFirstChild("Humanoid") and touched.Parent:GetAttribute("Midasable") == true and deb == false and touched.Parent:FindFirstChild("Humanoid").Health > 0 and Char:GetAttribute("Midas") == true then
			deb = true
			Char:SetAttribute("Midas", false)
			Char.Crown.Transparency = 1
			Char.Highlight:remove()
			alreadySubtracting = true
			game.SoundService.ping:Play()
			local highlight = Instance.new("Highlight", touched.Parent) -- Set the character variable to the character model of the targeted player
			highlight.Adornee = touched.Parent
			highlight.FillColor = Color3.new(1, 0.788235, 0.14902)
			highlight.FillTransparency = .2
			highlight.OutlineColor = Color3.new(1, 0.976471, 0.294118)
			touched.Parent:SetAttribute("Midas", true)
			touched.Parent.Crown.Transparency = 0
			touched.Parent:SetAttribute("Powered", false)
			adding = true
			for _, pw in game.Workspace[game.Workspace.GameManagement.MapSelection.Value]:GetChildren() do
				if pw.Name == "PowerUp" then
					if pw.Rval.Value == touched.Parent.Name then
						pw.Rval.Value = ""
						pw.PowerPlat.Color = Color3.new(1, 0.666667, 0)
						game.ReplicatedStorage.PWUsed:FireClient(game.Players[touched.Parent.Name])
					end
				end
			end
			
			Player.PlayerGui.Throw.Enabled = false
			game.Workspace.GameManagement.ArrowTargetName.Value = touched.Parent.Name
			wait(.5)
			deb = false
		end
	end)
	
	while true do
		wait(1)
		if Char:GetAttribute("Midas") == true and game.Workspace.GameManagement.GameActive.Value == true then
			Player.leaderstats.Points.Value += 1
			end
	end
end)

end)