Why isn't my explosion working?

So for some reason my second if statement isn’t firing for some reason. I’m not sure why and I tried multiple ways, but it doesn’t work for some reason. (It’s a fireball by the way. If it touches the sender then it ends. But, when it touches a wall for example it doesn’t activate).
Script:

Clone.Touched:Connect(function(Hit)
	local Humanoid = Player.Character:WaitForChild("Humanoid")

	if Creator then
		return
	end
	
	if Humanoid or not Humanoid then
		Humanoid.Health -= (FireballDamage)
		Clone.Anchored = true
		Tween:Play()
			wait(2)
		Clone:Destroy()
	end
	end)
end)

Thank you for reading.

1 Like

Did you try removing this? This might be the reason since it is returning end if Creator is true.

1 Like

it isn’t returning end, it is returning nothing

If you want it to return nothing do

if Creator then
	return ""
end

Because if you don’t do that, it thinks you are returning end.

and there people go again not knowing what I mean by nothing…

If you do print(""), it will print nothing. Not having anything between return and end will make it return end.

Do you mean 0 as nothing? Could you provide some details on what you mean by “nothing”?

If I remove this then it will damage the creator.

if I even attempt to explain my reasoning you won’t understand it
so I’m not going to bother trying

What I mean by “nothing” it does not fire this:

if Humanoid or not Humanoid then
	Humanoid.Health -= (FireballDamage)
	Clone.Anchored = true
	Tween:Play()
		wait(2)
	Clone:Destroy()
end
end)

end)

do you even know what replys are?

You could just simply play the Tween outside the conditional check?

    local DB = false

    Clone.Touched:Connect(function(Hit)
        Tween:Play()
	    local Humanoid = Player.Character:WaitForChild("Humanoid")

	    if Creator or DB then
		    return
	    end
	    DB = true

	    if Humanoid or not Humanoid then
		    Humanoid.Health -= (FireballDamage)
		    Clone.Anchored = true
			wait(2)
		    Clone:Destroy()
	    end
	end)
end)

too many ends in there by mistake

I’m aware, from what I recall (In @SilentSuprion’s posts) this is all inside a OnServerEvent function so an end) needs to be there to end it

Then it is returning end. You should have told me that it was returning end instead of “returning nothing”.

oh yea sorry my bad then
I should’ve checked

No, no. You do not seem to understand, what he means by “nothing” is literally nothing. It’ll return nil.

I don’t want

    if Humanoid or not Humanoid then
	    Humanoid.Health -= (FireballDamage)
	    Clone.Anchored = true
		wait(2)
	    Clone:Destroy()
    end
end)

end)
this part to play unless it isn’t the creator of the fireball.

Then just do return nil, because if you don’t put nil in, it will think you are returning end which is why the second if statement isn’t firing.

thank you
I didn’t really know how to explain without confusing them more

since nil and nothing mean the same exact thing

It can’t return end. It doesn’t work like that, because otherwise, there would be nothing to close the if statement.

@SilentSuprion, read below.

Regarding the main topic, we firstly have to get some issues addressed here. In the second line, you seem to reference Player, but did you ever make Player a variable in the first place? Because if you didn’t, of course, it’d return nil and give an error. Which also brings us to another question: was there any errors? Errors are crucial to finding the issue within the code, thus without them, it will be harder to solve this. Secondly, I personally recommend you to replace Humanoid.Health -= (Damage) with a built-in function for this (Humanoid:TakeDamage(Damage), although you should note this won’t bypass ForceFields.

That’s a bit of what I could notice, hope this helps.