local Players = game:GetService("Players") local RunService = game:GetService("RunService") local Workspace = game:GetService("Workspace") local lp = Players.LocalPlayer local Remote = Workspace:WaitForChild("Event"):WaitForChild("GunShotManage_RemoteEvent") local lastHealth = {} local function processTarget(model, originPart) local head = model:FindFirstChild("Head") local humanoid = model:FindFirstChildOfClass("Humanoid") if head and humanoid and humanoid.Health > 0 then if model:FindFirstChildOfClass("ForceField") then return false end if head:FindFirstChild("TeamMate") then return false end local myTeam = lp:GetAttribute("TeamNum") local targetTeam = model:GetAttribute("TeamNum") if targetTeam and myTeam and targetTeam == myTeam then return false end local originPos = originPart.Position local targetPos = head.Position local timestamp = Workspace:GetServerTimeNow() if lastHealth[model] and lastHealth[model] <= humanoid.Health then timestamp = timestamp + 0.1 end lastHealth[model] = humanoid.Health Remote:FireServer({ Data = { vector.create(originPos.X, originPos.Y, originPos.Z), vector.create(targetPos.X, targetPos.Y, targetPos.Z), head, vector.create(targetPos.X, targetPos.Y, targetPos.Z), vector.create(0, 0, 0), timestamp }, TYPE = "Shoot" }) return true else lastHealth[model] = nil return false end end RunService.Heartbeat:Connect(function() local char = lp.Character local originPart = char and char:FindFirstChild("Head") if not originPart then return end local playerFolder = Workspace:FindFirstChild("Player") if playerFolder then for _, targetModel in ipairs(playerFolder:GetChildren()) do if targetModel:IsA("Model") and targetModel ~= char then processTarget(targetModel, originPart) end end end end)