If statement not working

i was coding something for my fighting game, and an if statement was working but it randomly broke for no reason whatsoever, its not that theres errors it just isnt firing

ive tried using elseifs, formatting the code, but nothing worked

if player.Character.Humanoid.Health < 75 and player.Character.Humanoid.Health > 50 then
		explosionVFX.Size = explosionVFX.Size + Vector3.new(5,5,5)
		print(explosionVFX.Size)
	end
	if player.Character.Humanoid.Health < 50 and player.Character.Humanoid.Health > 25 then
		explosionVFX.Size = explosionVFX.Size + Vector3.new(10,10,10)
		print(explosionVFX.Size)
	end
	if player.Character.Humanoid.Health < 25 and player.Character.Humanoid.Health > 0 then
		explosionVFX.Size = explosionVFX.Size + Vector3.new(20,20,20)
		print(explosionVFX.Size)
	end

Try and check the values, maybe that could help

I think this only checks once. Instead do something like

Humanoid.Health.Changed:Connect(function()
your if statement
end)

the reason i formatted it this way is because its an ability that should add size to the hitbox of an attack depending on how low your health is

i dont fully understand what ur supposed to mean by that

ill try it right now, hold on im putting it in studio

you could still implement this. check if the humanoid health changes, and then check if the humanoid health is greater or less than your number, and then change the hitbox size. Or you could put this into a while true do loop, idk.

There are multiple if statements. Do all of them not run?

i did try it, but it wouldnt work anyways because this is a script fired from a client script, so if i wanted it to work id have to be damaged and use the move at the same time which due to stuns isnt gonna happen, also it didnt work

baki-slap-baki

originally it was elseifs, but i changed them in hopes it would work, it didnt, and none of them even run, i put print statements to make sure it works but it doesnt

How are you testing the if statements?

1 Like

i put a print inside of the if statement, so if its firing itll print the msg aswell

Are they being run in a health changed event or just once, when the script starts up?

the health changed event wouldnt work i just said this, the ability is fired by a tool meaning it isnt always running meaning id have to get damaged and use the move at the same time for it to work, and its not possible due to the stuns i made

and the script worked before, but it just randomly broke for some reason

‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭‮‭Ok

Just do the thing I told you

Debug the values And see what’s going on

dude wdym debug the values tho u never elaborated

He means print the health before if statement

1 Like