.Hit not working, if you solve my problem you get +100 social credits

I have apart of a script which just isnt working. Im trying to deal damage witth this explosion in a fireball. Though its not working. no errors in the output. Boom is already defined as an instance.new(explosion) earlier in the script. this is just the part that isnt working. No errors in the output. this is a local script inside a tool.

		boom.Hit:connect(function(hit) 
			if  hit  ~= nil and hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character and hit.parent  ~= nil  then
				local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
				humanoid1:TakeDamage(50)



			end
		end)
		

Using takedamage on the client will cause the humanoid to locally take damage. Put this code in a server script.

The explosion comes from a fireball that does damage already. so thats not the issue

This will locally damage the humanoid. The explosion being made on the server will not allow a local script to damage people globally. If this isn’t the issue try using debugging methods to see if the script gets passed the if statements.

1 Like

So I just realised something. Damage is dealt twice when the fireball hits a dummy meaning the script only fires when it hits a humanoid

Because i have another code block that runs when the fireball collides with a humanoid

It could also fire multiple times if it hits multiple different parts of a character. Make sure that’s not the problem.

But how would that stop the explosion itself from dealing damage, (when a humanoid is next to it, not colliding with the fireball because the fireball does damage on its own)

I’m saying that the problem is that explosion.hit is returning more than one part of a character. The problem you are facing is that it might hit the character 20 times dealing 20 times more damage.

Thats not the issue since it only deals damage twice. The function only deals damage when the fireball hits someone, I want it to deal damage when someone is hit by the explosion

I don’t understand why the script you wrote (assuming you fixed it being local) wouldn’t work in this situation. It should deal damage to humanoids that are hit by the explosion, right?

Ya, Its weird… Maybe its a bug or something

Did you try debugging the script to see if it’s getting past the if statements?

Ya, I have 2 print statments, one before the if statment and one after. They both only fire when the fireball hits the target

So it doesn’t print when they get hit by the explosion?

what if you change the

hit.Parent ~= player.Character

to

game.Players:GetPlayerFromCharacter(hit.Parent)

Well the fireball automatically explodes on impact with a player. In this part of the script, the part were talking about is supposed to deal damage to whoever is hit by the explosion that is caused when it hits a part and a player. Though the function is firing when it hits the player and not a part.
Hopefully that makes sense

boom.Hit:connect(function(hit) 
			if  hit  ~= nil  and hit.Parent ~= player.Character and hit.Parent  ~= nil and hit.Parent:FindFirstChild('Humanoid',true)  then
				local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
				humanoid1:TakeDamage(50)

			end
		end)

Doesnt work


	boom.Touched:Connect(function(hit) 
		local human = hit.Parent:FindFirstChildOfClass('Humanoid') 
		if human ~= nil and hit:IsDescendantOf(player.Character) == false  then
			human:TakeDamage(50)
		end
	end)

Maybe this will work

didnt work, .touched isnt compatible with explosions