✓ Accepted answer
- :GetDescendats() Gets Everything Including Model Names. So use :GetChildren()
- target.("Humanoid") does not need that infact it needs target:FindFirstChild("Humanoid")
2.5. ("Humanoid") is not required but you could use ["name here"] if it has any special characters.
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)
1 comment
Help me lol