Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ServerScriptService.FireBallServer:70: attempt to index nil with 'FindFirstChild'?

										Explosion.Touched:Connect(function(humTouched)
						if humTouched.Parent:FindFirstChild("Humanoid") and humTouched.Parent.Name ~= Player.Name then
							local EnemyHumanoid = humTouched.Parent.Humanoid
							EnemyHumanoid:TakeDamage(dmg)
						end
					end)

My script is having problems with dealing damage to other players and npcs and i cant really figure out the problem since ive checked all my spelling and nothing is wrong

1 answer

Dont use a LocalScript use a Script.

Explosion.Touched:Connect(function(hit)
	local Enemy = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
    if Enemy and Enemy.Character then
        local EnemyHumanoid = Enemy.Character:FindFirstChild('Humanoid')
		if EnemyHumanoid then
        	EnemyHumanoid:TakeDamage(dmg)
		end
    end
end)

This is a fixed version of your script.

2 comments

0

Thanks i will try this

0

It only damages players but doesnt damage npcs

This discussion is preserved as it was. New answers, comments, and votes are closed.