The script functions perfectly, only that it spams the developer console and the output to the point that I lag out or I can't find the error that I'm looking for. Here's the script, tell me what I can change to stop it from erroring.
PS THE SCRIPT WORKS FINE, JUST HELP ME WITH THE ERRORS
Parent = script.Parent
enabled = false
-- Variables
Parent.Touched:connect(function(hit)
player = game.Players:GetPlayerFromCharacter(hit.Parent)
wait()
if not enabled and hit.Parent ~= nil then
enabled = true
if not player and hit ~= nil and hit.Parent:findFirstChild("Humanoid").Health > 0 then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:WaitForChild("Humanoid").Health = hit.Parent:WaitForChild("Humanoid").Health - 20
end
elseif player and player.TeamColor ~= BrickColor.new("Black") then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:WaitForChild("Humanoid").Health = hit.Parent:WaitForChild("Humanoid").Health - 20
end
end
end
wait(3)
enabled = false
end)
09:21:09.768 - Workspace.FastRobloxian.Right Arm.Damage:10: attempt to index a nil value
09:21:09.769 - Stack Begin
09:21:09.769 - Script 'Workspace.FastRobloxian.Right Arm.Damage', Line 10
09:21:09.770 - Stack End
That's the error

2 comments
if the script has errors, then it doesn't work fine...
The thing is, the script DOES damage the humanoid, the debounce works perfect, but this error thingy is clogging up the output.