local Part = script.Parent
while true do wait()
local Check = workspace:GetPartsInPart(Part)
local Active = true
for i, v in ipairs(Check) do
if v.Parent then
local Humanoid = v.Parent:FindFirstChild("Humanoid")
if v.Name == "HumanoidRootPart" or Humanoid then
local Player = game.Players:GetPlayerFromCharacter(v.Parent)
local Damage = Player:WaitForChild("DamageActive")
if Damage then
if Damage.Value == true then
Active = false
game.Players:GetPlayerFromCharacter(v.Parent).DamageActive.Value = Active
v.Parent.Humanoid:TakeDamage(25)
print("Hit")
wait(1)
Active = true
if Damage then
Damage.Value = Active
end
elseif Damage.Value == false then
wait(1)
Damage.Value = true
end
end
end
end
end
end
Error I’m getting:
Workspace.Damage.Script:12: attempt to index nil with 'FindFirstChild'
Usually, when I get errors like this, I fix them by using the .CharacterAdded
event. But this error is happening on a while loop and I have no Idea how to fix this problem.
Plz help