script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("ParticleEmitter") or ("Nozzle") then
script.Parent.Fire.Enabled = false
end
end)
Now the issue is it ignores the if statement and will turn off the fire if it touches anything. What i would like the script to do is turn of the fire when it is touched by a ParticleEmitter but i am having toubles.
I don’t understand what i am doing wrong as i beleive i have done everything correct so any help will be appreciated! Yes i know this is only a small simple post which also means i hope for a small simple answer but yet again, any help is highly appreciated! - NathanPlays2016
It’s because of the or Nozzle part, you’re checking if a string is truthy there, which it almost always is
You have to give something to compare with nozzle, if you’re checking if the name is Nozzle, then you have to compare the name of “hit” with Nozzle or what you were planning on doing
if hit:FindFirstChild("ParticleEmitter") or hit.Name == "Nozzle" then
I have changed the script to your layout but there is a new issue. The part now does not detect when anything touches it. Here is the new script:
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("ParticleEmitter") or hit.Name == "Nozzle" then
script.Parent.Fire.Enabled = false
end
end)
Maybe it could be how your hose works? Can you try to rename one your legs to Nozzle using the explorer during testing/inserting a ParticleEmitter to ensure the if statement is working correctly?
what would be hit exactly? is it a transparent part? can you use some print statements too like
script.Parent.Touched:Connect(function(hit)
if hit.Name == "Nozzle" then
print("found emmiter")
script.Parent.Fire.Enabled = false
end
if hit:FindFirstChild("ParticleEmitter") then
print("found emmiter")
script.Parent.Fire.Enabled = false
end
end)