NumberValue changed function not working?

I have this script that when the parent value changes, it fires and does what its supposed to, but it doesn’t work and gives no output. Any help?

local function choosingthing(value)

print("changed health")

if value <= 0 and script.Parent.Parent.PutOut.Value == false then

print("fire health is below or = to 0")

script.Parent.Parent.PutOut.Value = true

script.Parent.Parent.Boom:Play()

for _,v in pairs(script.Parent.Parent:GetChildren()) do

if v.ClassName == "ParticleEmitter" then

v.Enabled = false

script.Parent.Parent.Heat.Enabled = false

script.Parent.Parent.FireBurning:Stop()

end

end

else

if value > 0 and script.Parent.Parent.PutOut.Value == false then

print("fire health is above 0")

for _,v in pairs(script.Parent.Parent:GetChildren()) do

if v.ClassName == "ParticleEmitter" then

print("got all classes of particleemitter")

v.Enabled = true

print("enabled all classes of particleemitter")

script.Parent.Parent.Heat.Enabled = true

print("enabled light")

end

end

end

end

end

script.Parent.Changed:Connect(choosingthing)

How are you particularly changing the Value? Remember that Scripts run on the server and any changes made by clients or LocalScripts will not replicate.

Also, please use indentation and variables - they’ll make your life a lot easier.

Its all changed on the server yes, it just doesn’t work idk why.

Where is the Script located? The Script could possibly not be running.

It runs, it just doesn’t work.

in the console, what prints do you see, do you see the “change health” print, if so then please say what other prints you see, if not then it has to do with the value being changed.

Oddly enough, it hasn’t been saying any prints up until when I just tested it again, using this code, it has only printed once, and the wrong print from what its really supposed to.

script.Parent.Changed:Connect()

print("changed health")

if script.Parent.Value <= 0 and script.Parent.Parent.PutOut.Value == false then

print("fire health is below or = to 0")

script.Parent.Parent.PutOut.Value = true

script.Parent.Parent.Boom:Play()

for _,v in pairs(script.Parent.Parent:GetChildren()) do

if v.ClassName == "ParticleEmitter" then

v.Enabled = false

script.Parent.Parent.Heat.Enabled = false

script.Parent.Parent.FireBurning:Stop()

else

if script.Parent.Value > 0 and script.Parent.Parent.PutOut.Value == false then

print("fire health is above 0")

for _,v in pairs(script.Parent.Parent:GetChildren()) do

if v.ClassName == "ParticleEmitter" then

print("got all classes of particleemitter")

v.Enabled = true

print("enabled all classes of particleemitter")

script.Parent.Parent.Heat.Enabled = true

print("enabled light")

end

end

end

end

end

end

print("changed")

This doesn’t do anything. You need to give it a function to call

script.Parent.Changed:Connect(function()
    -- put your stuff here
end)

or

script.Parent.Changed:Connect(yourFunctionName)

Its still giving me the wrong answer, when I change the parent value to 500, this is what fires, and its giving me the <= 0 one?

What does this output, since it will output something, error or a print.
If it outputs nothing, check if the script is disabled.
All I changed was formatting and the first if statement to have a elseif.

script.Parent.Changed:Connect(function()
	print("changed health")

	if script.Parent.Value <= 0 and script.Parent.Parent.PutOut.Value == false then
		print("fire health is below or = to 0")
		script.Parent.Parent.PutOut.Value = true
		script.Parent.Parent.Boom:Play()

		for _, v in pairs(script.Parent.Parent:GetChildren()) do
			if v.ClassName == "ParticleEmitter" then
				v.Enabled = false
				script.Parent.Parent.Heat.Enabled = false
				script.Parent.Parent.FireBurning:Stop()
			end
		end
	elseif script.Parent.Value > 0 and script.Parent.Parent.PutOut.Value == false then
		print("fire health is above 0")

		for _, v in pairs(script.Parent.Parent:GetChildren()) do
			if v.ClassName == "ParticleEmitter" then
				print("got all classes of particleemitter")
				v.Enabled = true
				print("enabled all classes of particleemitter")
				script.Parent.Parent.Heat.Enabled = true
				print("enabled light")
			end
		end
	end

	print("changed")
end)


script.Parent.Value = 10

I guess it fixed with the elseif, I took away the changing the value to 10 thing.

I had the same issue, thanks to you it’s fixed :+1: