I want the humanoids to take 10 damage every time I hit them.
The humanoids for some reason take no damage despite the script detecting that they should take damage and there not being any errors.
I have tried a variety of different ways to damage humanoids including humanoid.Health -= 10 and humanoid:TakeDamage(10) but none seem to work. I have also tried this on different npc models and even on players but that makes no difference.
local RunService = game:GetService("RunService")
local tool = script.Parent
local handle = tool.Handle
local remotes = tool:WaitForChild("Remotes")
local config = tool:WaitForChild("Config")
local damage = config:GetAttribute("Damage")
local hitdebounce = {}
remotes.ToolActivated.OnServerEvent:Connect(function(player)
local char = player.Character
local touch
touch = handle.Hitbox.Touched:Connect(function(hit)
if table.find(char:GetDescendants(), hit) == nil and table.find(hitdebounce, char) == nil and char:FindFirstChild("Humanoid") then
print(damage)
print(hit.Parent.Humanoid.Health)
table.insert(hitdebounce, char)
char.Humanoid:TakeDamage(damage)
print(hit.Parent.Humanoid.Health)
end
end)
wait(.5)
touch:Disconnect()
table.clear(hitdebounce)
end)
Have you tried taking damage on the client side in a local script? Based on the documentation I’ve seen, it works if it’s on the client from the example code.