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.
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")
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