False ping hit triggers in game

What hit detection method are you using?

1 Like

Is this causing this player to be able to shoot the person multiple times and deal more damage than they usually would? Or is it just an insane delay? I can’t really tell by the video due to camera angles, sorry.

its false info related the player shoots the enemy gets an alert that they hit the enemy but dont actually hit the enemy.

we use raycasts from a local script with player inputs

inputs from client and raycast from server response to client right?

Maybe try to remake your system using this resource

apparently it accounts for lag

“Bullets that move extremely smoothly and consistently. The best part is that since I use Heartbeat, the bullet will accommodate for lag. In the event of any lag, the cast will move how much it should’ve moved as if there was no lag at all, ensuring that it stays on time and remains consistent to the motion values you specifed.”

@TakoDeCat

2 Likes

it should but it triggers like it should but never actually goes to server side. no errors on inf yields

i just checked it out and i dont think this is what we need since we dont have slow projectiles ours is completly hit scan with instant show( gun doesnt even have a tracer or any form of physical bullet)

did this player manage to relay how high their ping was?

I’m pretty sure you can modify FastCast settings to work with fast projectiles. However, I don’t think it would fix the issue if it’s a problem with something not being sent from the client to the server.

Is there some sort of RemoteEvent that isn’t firing correctly?

yep we tested with multiple high ping players it starts at around 120 ping and gets worst at 350.

Well maybe show us the code you’re working with then maybe we can offer a solution, poke around maybe see what’s up

we dont know there arent any errors or inf yields
everything acts normal, local shows hit notification that should only happen on hit and server doesnt transfer the gun

Have you tried printing out when something on the server side hits and checked if it printed?

As @finaIlyhappy said, could you provide the code? Maybe add a few print statements to check exactly where the error is- if there’s a RemoteEvent being triggered on the client and not being recieved on the server I doubt it’s a lag-related issue.

3 Likes

if you are hit detecting on client it might be missing on the server side, you should probably make the hit detector have some idea of where the server side one is.

Although I really don’t think a raycast should be this unresponsive at a ping of only 120 or 350…

ill try but it might take time the code has some stuff thats commented out i gotta sort from old issues give me a few minutes

1 Like

Are you using remote events to communicate between the server and the client?

yep a remote event from a local to a modular script

ignore anything commented out most of it is by my friend who made the script

modular script that handles anything gun related

function Shoot(Player, target, otherChar)
	
	warn("Shoot Request[RECIEVED]: " .. Player.Name.. " --> " .. otherChar.Name)
	
	if Player.Character == nil then
		return
	end
	local character = Player.Character
	if character:FindFirstChild("Humanoid") == nil then
		return
	end
	if character.Humanoid.Health == 0 then
		return
	end
	if GunFunctions.TryGetCharacterGun(character) == nil then
		return
	end
	
	--TEST IG COULD WORK BUT IDK
	if character:GetAttribute("GunTimer") <= 0 then
		return
	end

	local player = Players:GetPlayerFromCharacter(character)
	local Gun = GunFunctions.TryGetCharacterGun(character)
	
	
	if character:GetAttribute("GunEquipped") == true and character:GetAttribute("CanShoot") == true then
		
		if character:GetAttribute("Reloading") == false then
			



			--TRACER (this will be long)
			local ShowTracer = false


			local Muzzle = Gun:FindFirstChild("Muzzle")
			local TracerBeam = Muzzle:FindFirstChild("Beam")
			local TracerAtt0 = Muzzle:FindFirstChild("Att0")
			local TracerAtt1 = Muzzle:FindFirstChild("Att1")
			local MuzzleFlashP = Muzzle:FindFirstChild("MuzzleFlashParticle")
			local MuzzleFlashL = Muzzle:FindFirstChild("MuzzleFlashLight")

			if TracerAtt0 == nil or TracerAtt1 == nil or TracerBeam == nil --[[or target == nil]] then
				return
			end
			if TracerAtt0:IsA("Attachment") and TracerAtt1:IsA("Attachment") and TracerBeam:IsA("Beam") --[[ and typeof(target) == "Vector3"]] then

				local GunShotSound = Gun.GunSounds.GunShotSound
				
				AnimTracks.PlayPlayerAnim(player.Name, "ShootAnim")
				
				
				GunShotSound:Play()
				

				--[[
				local clonedAtt0 = TracerAtt0:Clone()
				clonedAtt0.Parent = TracerAtt0.Parent	
				local clonedAtt1 = TracerAtt1:Clone()
				clonedAtt1.Parent = TracerAtt1.Parent
				local clonedBeam = TracerBeam:Clone()
				clonedBeam.Parent = TracerBeam.Parent
				]]

					
				local clonedMFP = MuzzleFlashP:Clone()
				clonedMFP.Parent = MuzzleFlashP.Parent
				local clonedMFL = MuzzleFlashL:Clone()
				clonedMFL.Parent = MuzzleFlashL.Parent



				--[[
				clonedAtt1.WorldPosition = target
				clonedBeam.Attachment1 = clonedAtt1
				clonedBeam.Attachment0 = clonedAtt0
				]]


					--hacky fix but does for now
				local BeamPart = Instance.new("Part", workspace)
				BeamPart.Anchored = true
				BeamPart.Transparency = 1
				BeamPart.CanCollide = false
				BeamPart.CanQuery = false
				BeamPart.CanTouch = false
				BeamPart.CFrame = TracerAtt0.WorldCFrame


				--[[
				clonedAtt0.Parent = BeamPart
				clonedAtt1.Parent = BeamPart
				clonedBeam.Parent = BeamPart
				]]





				clonedMFP.Enabled = true
				clonedMFL.Enabled = true


				--[[
				Debris:AddItem(clonedBeam, 0.2)
				Debris:AddItem(clonedAtt0, 0.2)
				Debris:AddItem(clonedAtt1, 0.2)

				Debris:AddItem(BeamPart, 0.2)
				]]	
					

				Debris:AddItem(clonedMFP, 0.15)
				Debris:AddItem(clonedMFL, 0.15)



			end

			if otherChar == nil then
				return
			end
			
			local returnResult = false
			

				--local otherChar = rayresult.Instance:FindFirstAncestorOfClass("Model")
				local otherPlayer = Players:GetPlayerFromCharacter(otherChar)
				local Hum = otherChar:FindFirstChild("Humanoid")
				

				if Hum and Hum.Health ~= 0 and otherChar:GetAttribute("GunName") ~= nil--[[ and otherChar:GetAttribute("Ragdolled") ~= true]] then

					
					
					AnimTracks.StopPlayerAnim(player.Name, "ShootAnim")
					
					
					GunFunctions.UnequipGun(Player.Character)
					
					local GunTimer = character:GetAttribute("GunTimer")
					if GunTimer <= 0 then
						character.Humanoid.Health = 0
						return
					end
					
					--[[
					GunFunctions.EquipGun(otherChar)
					
					BE_SetRoundStatus:Fire(otherPlayer.Name .. " has the Gun!")
					]]
					
					
					
					task.spawn(function()
						
						warn("Shoot Request[CONFIRMED]: " .. Player.Name.. " --> " .. otherChar.Name)
						
						--tako insert
						if Player.Character:FindFirstChild("Humanoid") then
							Player.Character.Humanoid.WalkSpeed = 28

						end
						
						otherPlayer:SetAttribute("LastShotBy", Player.Name)
						
						BE_Ragdoll:Fire(otherChar)
						
						local humanoidRootPart = otherChar:FindFirstChild("HumanoidRootPart")
						
						local ForceAtt0 = Instance.new("Attachment", humanoidRootPart)
						local VectorForce = Instance.new("VectorForce", humanoidRootPart)
						
						
						local hitDirection = (humanoidRootPart.Position - Player.Character.HumanoidRootPart.Position).unit
						hitDirection *= Vector3.new(2900, 100, 2900)
						
						--warn(hitDirection)
						--[[
						-- Calculate the direction vector from the attachment to the target part
						local direction = (Player.Character.Torso.Position - ForceAtt0.WorldPosition).Unit

						-- Calculate the CFrame that points the attachment towards the target
						local lookAtCFrame = CFrame.lookAt(ForceAtt0.WorldPosition, Player.Character.Torso.Position)

						-- Apply the 180-degree rotation to the lookAtCFrame
						local rotatedCFrame = lookAtCFrame * CFrame.Angles(0, math.rad(180), 0)

						-- Apply the rotated CFrame to the attachment
						ForceAtt0.CFrame = rotatedCFrame
						
						]]
						
						
						--ForceAtt0.CFrame = ForceAtt0.CFrame * CFrame.Angles(0, math.rad(180), 0) 
						
						
						
						
						--[[
						
						if Hum.FloorMaterial == Enum.Material.Air then
							VectorForce.Force = Vector3.new(0, 0, 2000)
						else
							VectorForce.Force = Vector3.new(0, 0, 5000)
						end
						]]
						
						VectorForce.Force = hitDirection
						
						
						VectorForce.Attachment0 = ForceAtt0
						VectorForce.ApplyAtCenterOfMass = true
						
						
						
						
						
						task.wait(0.1)
						
						VectorForce:Destroy()
						ForceAtt0:Destroy()
						
						
						task.wait(1.6)
						
						if Player.Character:FindFirstChild("Humanoid") then
							Player.Character.Humanoid.WalkSpeed = 20

						end
						
						BE_UnRagdoll:Fire(otherChar)
						
						task.wait(0.2)
						
						GunFunctions.SetPlayerWithGun(otherPlayer)
					end)
					
					--Has to be spawned cuz it delays by 1 second idk WHYYYY (FIGURE OUT LATER IF IT HAS A PREF HIT)
					
					
					local GunHitSound = Gun.GunSounds.GunHitSound
					
					GunHitSound:Play()
					
					returnResult = true
					
				end
			
			Gun:SetAttribute("Magazine", Gun:GetAttribute("Magazine") - 1)
			
			GunFunctions.StartReloadTimer(character)
			return returnResult
		else
			
		end
		
	else

	end
	
end


RF_ShootRequest.OnServerInvoke = Shoot

local side

function Input(input)
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 and Player:GetAttribute("AssetsLoaded") then
		
		--centerTestPart.CFrame = CFrame.new(ViewportPointToWorldCoordinates())
		local Humanoid = Character:FindFirstChild("Humanoid")
		
		if Humanoid == nil then
			return
		end
		
		if Character:GetAttribute("CanShoot") == true and Character:GetAttribute("Reloading") == false and Character:GetAttribute("GunTimer") > 0 and Humanoid.Health > 0 then
			
			local  target = ViewportPointToWorldCoordinates()
			
			if DebugSwitch then
				local debugPart = Instance.new("Part", game.Workspace)
				debugPart.Name = "DebugShootPart"
				debugPart.Anchored = true
				debugPart.CanCollide = false
				debugPart.CanTouch = false
				debugPart.CanQuery = false
				debugPart.Transparency = 0.5
				debugPart.Shape = Enum.PartType.Ball
				debugPart.BrickColor = BrickColor.new(Color3.fromRGB(255, 176, 0))
				debugPart.Position = target
				
				Debris:AddItem(debugPart, 10)
			end
			
			local rayParams = RaycastParams.new()
			rayParams.FilterType = Enum.RaycastFilterType.Exclude
			rayParams.FilterDescendantsInstances = {Player:GetDescendants(), Character:GetDescendants()}

			local rayCast = Ray.new()

			local originPoint = Character:FindFirstChild("Head").Position
			local rayDestinationPoint = target
			local rayDirectionWay = (rayDestinationPoint - originPoint).Unit

			local rayresult = workspace:Raycast(originPoint, rayDirectionWay * 300, rayParams)
			local intersection = rayresult and rayresult.Position or originPoint + rayDirectionWay * 300
			local distance = (originPoint - intersection).Magnitude
			
			if rayresult.Instance:FindFirstAncestorOfClass("Model") ~= nil then
				
				local otherChar = rayresult.Instance:FindFirstAncestorOfClass("Model")
				
				--warn(otherChar.Name)
				
				task.spawn(Recoil)
				
				
				local Hum = otherChar:FindFirstChild("Humanoid")


				if Hum and Hum.Health ~= 0 and otherChar:GetAttribute("GunName") ~= nil then
					
					task.spawn(function()
						
						if HitLabel.Visible == false then
							
							HitLabel.Visible = true

							HitPlayerLabel.Visible = true
							
						end
						
						Hitmarker.Visible = true

						HitPlayerLabel.Text = otherChar.Name
						
						

						task.wait(0.3)

						Hitmarker.Visible = false
						
						task.wait(0.2)
						
						if HitLabel.Visible == true then
							
							HitLabel.Visible = false

							HitPlayerLabel.Visible = false
							
						end
						
						
					end)
					
				end
				
				
				RF_ShootRequest:InvokeServer(target, otherChar)
				
				
			end
			
			--[[
			task.spawn(Recoil)
			
			if target then
					
				local result = RF_ShootRequest:InvokeServer(target)	
				
				if result == true then
					--DO STUFF HERE ON CLIENT IF HIT
					
					
				end
			end
			
			]]
		else

		end
		
	end
	
	
	if input.KeyCode == Enum.KeyCode.F3 then
		if DebugSwitch == true then
			DebugSwitch = false
			
			NotifModule.UINotify("disabled hit visualisation", 24)
			
		else
			DebugSwitch = true
			
			NotifModule.UINotify("enabled hit visualisation", 24)
		end
	end
	
end

UIS.InputBegan:Connect(Input)