What do you want to achieve? Keep it simple and clear!
A lightsaber that does not error when recognizing the target.
What is the issue? Include screenshots / videos if possible!
“Attempted to index nil with Health”
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
None worked.
Tool.contact.Touched:Connect(function(touch)
if Equipped and debounce == false then
if touch.Parent:FindFirstChildWhichIsA("Humanoid") and touch:FindFirstAncestorWhichIsA("Player") ~= playeruser then
debounce = true
touch.Parent:FindFirstChild("Humanoid").Health -= (20)
LightSaberHitSounds[math.random(1,4)]:Play()
wait(1)
debounce = false
elseif touch.Parent.Parent:FindFirstChildWhichIsA("Humanoid") then
debounce = true
touch.Parent:FindFirstChild("Humanoid").Health -= (20)
LightSaberHitSounds[math.random(1,4)]:Play()
wait(1)
debounce = false
end
end
end)