Error with nuclear blast damage-script

Hi, I’m making a nuclear airstrike tool. Basically what I’ve done, is managed to make the nuclear warhead drop and explode. My only issue is the damage on touch with the expanding nuclear explosion. Here’s the main script with issues:

local impactFrame2 = require(game.Workspace.ImpactFrames) impactFrame2:CreateAlternating(0.2,0.05) --create impact2

local dmgTween = game:GetService("TweenService"):Create(script.Parent.CurrentDmgAmount, TweenInfo.new(1), {Value = 1})
dmgTween:Play() --as the fireball expands, lower damage amount on hit




script.Parent.Touched:Connect(function(hit)
	
	local hum = hit.Parent:FindFirstChild("Humanoid") --find humanoid

	if hum and hum.Parent.IsRagdoll.Value == false and script.Parent.Name == "chezNukeBLAST" then --makes sure the player can't be hit more than once, and make sure the fireball is the actual damage dealing fireball, since another script creates 2 other delayed fireballs for visuals.
			print(hit.Parent.Name) --debug
		
		
		local plrFound = game.Players:GetPlayerFromCharacter(hit.Parent) --attempt to find the player from the character
		
		game.ReplicatedStorage.cueCheeseNukeClientFX:FireClient(plrFound) -- cue the flashbang effect with the remote event
		if script.Parent.protectedChar.Value ~= hit.Parent then --make sure the player that was hit is not the ability user.
		hum:TakeDamage(script.Parent.CurrentDmgAmount.Value) --deal the damage to the victim
		hum.Parent.IsRagdoll.Value = true --temporaily ragdoll the victim so they can't get hit again
		wait(2)
		hum.Parent.IsRagdoll.Value = false
		
		end
	
	end
end)

errors im getting:

22:18:08.310  Workspace.chezNUKEBLAST.MAIN:11: attempt to index nil with 'FindFirstChild'  -  Server - MAIN:11

any help appreciated!

1 Like

maybe this workaround would work?
remove where you define hum and in the if statement do something like if hit.Parent:FindFirstChild(“Humanoid”) (then replace hum with this) and then you can define it inside the statement

try replacing line 11 with this:


if Part.Parent and Part.Parent:FindFirstChild("Humanoid") then
local hum = Part.Parent:FindFirstChild("Humanoid")
end

indentation broke when i edited

yup, this is what i tried to say, but part.parent will always be true, so you could instead say
if part.parent ~= workspace

didn’t work. no errors or anything

try replacing findfirstchild with findfirstchildofclass?