Hello, im trying to script a flamethrower and I have made a part which is welded to the gun mesh. I have a script that detects if the player touches that part and the flamethrower is shooting it damages the player. When I add an if statement to check if the fire particles from the flamethrower are turned on,the script breaks. Without the if statement it damages the player, but the problem is that it damages the player all the time. I have tried many ways of debugging it but I cannot find out how to fix it.
The script:
local part = script.Parent
local touching
local emitter = script.Parent.Parent.Shoot.ParticleEmitter
part.Touched:Connect(function(other)
print ("Hi")
local hum = other.Parent:FindFirstChild("Humanoid")
if hum then
if emitter.Enabled == true then
print("No")
touching = true
while touching == true do
print("Bye")
hum:TakeDamage(3.5)
wait(0.3)
end
end
end
end)
part.TouchEnded:Connect(function()
print("Ended")
touching = false
end)
Thanks in advance.