If and statement keeps running if only one condition is met

I have a couple of questions.

  1. Do the particles duplicate for the head only or every other limb as well?
  2. Does it duplicate more than once? (More than two instances of the same aura)
  3. Does this occur every value after 5? Since youve only created 5 and up.

Edit for new question

  1. every body part
  2. every kill after the phase is first initalized dupes the particles so yes

trying print debugging, and if (char.Phase.Value == 5 and particles == false) then keeps printing and duping particles when it literally sets particles to true after… char.Phase.Value is 5 but particles is true so the code block shouldn’t run…

Does the value remain at 5 or does it change? Kindly try adding a print when the particles are parented to the limb then check after 2 kills. If it prints twice then we can rule out other scripts interfering with it.

value remains at 5 until the next phase is reached

I have a bandaid fix for now with check to see if it runs more than once. For this to work, youd have to change the pclones children models to the actual limb name (ie. “RArm” to “Right Arm”). What I did is check if the aura doesnt exist, then it parents the particle. Let me know if it works and if ‘Check’ prints after every kill.

		if (char.Phase.Value == 5) and (particles == false) then
			particles = true
			print('Check')

			local pclone = game.ServerStorage:WaitForChild("Phase5"):Clone()
			
			for _, limb in pairs({"Head", "Torso", "Left Arm", "Right Arm", "Left Leg", "Right Leg"}) do -- This just gets the table of limb names and finds the respective aura from pclone.
				for _, aura in pairs(pclone[limb]:GetChildren()) do
					if not char[limb]:FindFirstChild(aura.Name) then
						aura.Parent = char[limb]
					end
				end
			end
			pclone:Destroy()	
		end

EDIT: Moved print Check after setting particles to true

No way, but it actually worked. It doesn’t duplicate the particles anymore…
Thanks a whole bunch!

2024 edit: Found out it was the old code causing the problem. For some reason the tutorial I originally followed on how to make a slap battles game disables and enables the script after slapping people, for some reason and is why the bug even happened. However, I did end up splitting the glove script and the aura script, which works flawlessly. If one of you guys or the solver comes back, sorry for wasting time if you’re taking it that way, but thanks for all the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.