I am trying to create a script that burns you when you touch a part but I have three "if end" statements in a row which is why I believe it is not working.
if humanoid then if not firecheck then if not smokecheck then
Please try to fix this for me and explain what I did wrong so I know what to do for next time.
local lava = script.Parent local fire = Instance.new("Fire") local smoke = Instance.new("Smoke") lava.Touched:connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") local firecheck = hit.Parent.Torso:FindFistChild("Fire") local smokecheck = hit.Parent.Torso:FindFistChild("Smoke") if humanoid then if not firecheck then if not smokecheck then end fire.Parent = hit.Parent.Torso smoke.Opacity = 0.1 smoke.Parent = hit.Parent.Torso for steps = 1, 10, 1 do humanoid:TakeDamage(5) wait(1) end fire:Destroy() smoke:Destroy() end end end)
First and foremost: Scripts using "Torso" will ONLY work in R6 mode. Just a heads up.
I see a couple problems here. First of all, you should move your creation of the fire and the smoke to after your "if" checks. The way it currently is, it would only give one player fire and smoke and then would not do it again. If you move them, it will check if the character has them, and once it finds out they do not, it will make them.
It appears that the main reason your script is not working is a misplaced "end".
This should fix it
local lava = script.Parent lava.Touched:connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") local torso = humanoid.Parent:FindFirstChild("Torso") local smokecheck = hit.Parent.Torso:FindFistChild("Smoke") if humanoid then if torso then local firecheck = torso:FindFirstChild("Fire") if not firecheck then local fire = Instance.new("Fire", torso) local smokecheck = torso:FindFirstChild("Smoke") if not smokecheck then local smoke = Instance.new("Smoke", torso) fire.Parent = hit.Parent.Torso smoke.Opacity = 0.1 smoke.Parent = hit.Parent.Torso for steps = 1, 10, 1 do humanoid:TakeDamage(5) wait(1) end fire:Destroy() smoke:Destroy() end end end end end)
I apologize for any spacing that's off. I had to do this without a tab button. Hopefully this works for you.
Having 3 ifs is quite easy to make look here
if humanoid then elseif not firecheck then elseif not smokecheck then
elseif's will work similar to else's but they can be used an unlimited ammount of times and kinda work like if's!