Error:
Workspace.Quota.HitVal:9: attempt to index nil with 'Name'
current code:
local player = game:GetService("Players")
local Debounce = false
while true do
for i, v in ipairs(player:GetChildren()) do
local cash = v:WaitForChild("leaderstats").Sacrifices
script.Parent.Touched:Connect(function(touchingPart)
-- NORMAL NPC
if touchingPart.Parent.Name == "NPC" and Debounce == false then
Debounce = true
cash.Value = cash.Value + 1
touchingPart.Parent:Destroy()
wait(0.1)
script.Parent.Effects.BLOOD01.Enabled = true
script.Parent.Effects.BLOOD02.Enabled = true
script.Parent.Effects.BLOOD03.Enabled = true
script.Parent.Effects.BLOOD04.Enabled = true
script.Parent.Effects.BLOOD05.Enabled = true
script.Parent.Effects.BloodHit.Enabled = true
script.Parent.Blood:Play()
script.Parent.ChainSaw:Play()
wait(1)
script.Parent.Effects.BLOOD01.Enabled = false
script.Parent.Effects.BLOOD02.Enabled = false
script.Parent.Effects.BLOOD03.Enabled = false
script.Parent.Effects.BLOOD04.Enabled = false
script.Parent.Effects.BLOOD05.Enabled = false
script.Parent.Effects.BloodHit.Enabled = false
script.Parent.Blood:Play()
script.Parent.ChainSaw:Play()
-- STABBING NPC
elseif touchingPart.Parent.Name == "Stabman" and Debounce == false then
Debounce = true
cash.Value = cash.Value + 2
touchingPart.Parent:Destroy()
wait(0.1)
script.Parent.Effects.BLOOD01.Enabled = true
script.Parent.Effects.BLOOD02.Enabled = true
script.Parent.Effects.BLOOD03.Enabled = true
script.Parent.Effects.BLOOD04.Enabled = true
script.Parent.Effects.BLOOD05.Enabled = true
script.Parent.Effects.BloodHit.Enabled = true
script.Parent.Blood:Play()
script.Parent.ChainSaw:Play()
wait(1)
script.Parent.Effects.BLOOD01.Enabled = false
script.Parent.Effects.BLOOD02.Enabled = false
script.Parent.Effects.BLOOD03.Enabled = false
script.Parent.Effects.BLOOD04.Enabled = false
script.Parent.Effects.BLOOD05.Enabled = false
script.Parent.Effects.BloodHit.Enabled = false
script.Parent.Blood:Play()
script.Parent.ChainSaw:Play()
end
end)
end
wait(1)
Debounce = false
end
The system works fine, but I keep getting the error which is causing lag. I’m not even sure why this is happening, but I’m guessing it might be because once the block is dropped and after it deletes then the script is wondering it’s name. I have a debounce though so I’m not sure why it isn’t working. Anyone have a solution?