Hello, recently i've been working on a fire and water script in which someone jumps into lava and takes damage, then jumps into the water and clears all the effects from the fire. This is my script for both.
local firePart = script.Parent local Players = game.Players firePart.Transparency = 1 local Lava = function(hitPart) if hitPart.Parent:FindFirstChild("Humanoid") then hitPart.Parent.Humanoid.Health = hitPart.Parent.Humanoid.Health - 3 if hitPart.Parent.Humanoid.Health > 0 then local Parts = hitPart.Parent:GetChildren() for i, Parts in pairs(Parts) do if Parts:IsA("BasePart") then Instance.new("Fire", Parts) Instance.new("Smoke", Parts) end end end end end firePart.Touched:Connect(Lava)
thats my Fire script, and this next one is my water script
local waterPart = script.Parent waterPart.Transparency = 1 local function PutOutFire(part) local human = part:FindFirstChild("Humanoid") for i, human in pairs(human) do if human:FindFirstChild("Smoke") then human:FindFirstChild("Smoke"):Destroy() end if human:FindFirstChild("Fire") then human:FindFirstChild("Fire"):Destroy() end end end waterPart.Touched:connect(PutOutFire)
I am not sure where am going wrong, I don't get any errors, but the smoke and fire effect from the fire script doesn't leave even after I jump into the water. What do I need to change, and how can I make this better? Help will be much appreciated.
You're looking for humanoid in the part hit, and checking for smoke and fire in the humanoid(which is nil)
fix:
local waterPart = script.Parent waterPart.Transparency = 1 local function PutOutFire(part) if part.Parent.Humanoid then local human = part.Parent:GetChildren() for i, human in pairs(human) do if human:FindFirstChild("Smoke") then human:FindFirstChild("Smoke"):Destroy() end if human:FindFirstChild("Fire") then human:FindFirstChild("Fire"):Destroy() end end end end waterPart.Touched:connect(PutOutFire)