No response at conditional if not hit.Parent == plr.Character then

I wanted to practice by scripting a very simple “fireball attack”, the visuals and everything else works perfectly, however,

script.Parent.abilityuse.OnServerEvent:Connect(function(plr)
	local projectile = game.ServerStorage.assets.fireball:Clone()
	projectile.Parent = workspace
	projectile.CFrame = plr.Character:WaitForChild("Right Arm").CFrame * CFrame.new(0,0,-1)
	projectile:FindFirstChild("BodyVelocity").Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 100
	
	projectile.firework:Play()
	game.Debris:AddItem(projectile,3)
	
	projectile.Touched:Connect(function(hit)

		if hit.Parent:FindFirstChild("Humanoid") then
			if not hit.Parent == plr.Character then
				hit.Parent.Humanoid:TakeDamage(5)
				print("Damage")
				local boom = game.ServerStorage.assets.firespread:Clone()
				boom.Parent = workspace
				boom.CFrame = projectile.CFrame
				for i = 1,15 do
					boom.Size = boom.Size * Vector3.new(1.12,1.12,1.12)
					boom.Transparency = boom.Transparency+0.066
					wait(0.01)
				end
				boom.ParticleEmitter.Enabled = false
				game.Debris:AddItem(boom,2)
				end
		end
	end)
	
end)

The issue lays specifically at line 13, if not hit.Parent == plr.Character then, it was a conditional added to prevent the script from targeting the player, but it just makes the fireball ignore any humanoid, the output is clean, and I’ve no idea of what the problem might be, though it’s most likely I am using the conditional wrong. Additionally, if anyone knows a more efficient form for this script, I beg you to input.

Try something like if hit.Parent ~= plr.Character then
It’s ignoring every humanoid because it’s only accepting the caster as the target, so that means nobody else would be hit. ~= will make sure it’s ignoring the caster’s character.

Can you show us the script of these lines?

game.Debris:AddItem(projectile,3)
game.Debris:AddItem(boom,2)

I don’t see any problems with this script.

Yes! That did the trick, thank you very much.

local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local Server = game:GetService("ServerStorage")

local Parent = script.Parent
local Ability = Parent.abilityuse

local Assets = Server.assets
local Fireball = Assets.fireball
local Boom = Assets.firespread

Parent.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	local RightArm = Character:FindFirstChild("Right Arm")
	local HRP = Character:FindFirstChild("HumanoidRootPart")
	if RightArm then
		local Projectile = Fireball:Clone()
		Projectile.Parent = workspace
		Projectile.CFrame = RightArm.CFrame * CFrame.new(0, 0, -1)
		Projectile.BodyVelocity.Velocity = HRP.CFrame.lookVector * 100
		Projectile.firework:Play()
		Debris:AddItem(Projectile, 3)

		Projectile.Touched:Connect(function(Hit)
			local HitModel = Hit:FindFirstAncestorOfClass("Model")
			if HitModel then
				local HitPlayer = Players:GetPlayerFromCharacter(HitModel)
				if HitPlayer then
					if HitPlayer == Player then
						return
					end
					
					local HitHumanoid = HitModel:FindFirstChildOfClass("Humanoid")
					if HitHumanoid then
						HitHumanoid:TakeDamage(5)
					end
					
					local BoomClone = Boom:Clone()
					Boom.Parent = workspace
					Boom.CFrame = Projectile.CFrame
					for i = 1, 15 do
						task.wait(0.01)
						Boom.Size += Vector3.new(1.12, 1.12, 1.12)
						Boom.Transparency += 0.066
					end
					Boom.ParticleEmitter.Enabled = false
					Debris:AddItem(Boom, 3)
				end
			end
		end)
	end
end)

Just some improvements here and there, if you’d like me to explain, let me know.