game.ReplicatedStorage.Remotes.Punch.OnServerEvent:Connect(function(player,damage) for i,target in pairs(game.Workspace:GetDescendants()) do if target.("Humanoid") and target.Parent.Name ~= player.Name then if (target.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude <5 then target.Character.Humanoid.Health -= damage end end end end)
I don't know the problem on line 3 its so annoying :/
tip: tip 2.5 doesnt work on everything so if you have a object called "dh h8" you do not need to code it like parent:FindFirstChild("["dh h8"]") you need to code it like parent:FindFirstChild("dh h8") or parent:FindFirstChild([["dh h8"]]) -- anything inside the double brackets count as a string
your modifyed code would look like:
game.ReplicatedStorage.Remotes.Punch.OnServerEvent:Connect(function(player,damage) for i,target in pairs(game.Workspace:GetChildren()) do if target:FindFirstChild("Humanoid") and target.Parent.Name ~= player.Name then if (target.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude <5 then target.Character.Humanoid.Health -= damage end end end end)