Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Whats causing my script to not produce any results?

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.

1 answer

✓ Accepted answer

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)

4 comments

0

whoooo, it worked! I have a few questions about it though, for example do you mean Humanoid is nil? If so, how do I know if it is or not? Sorry am kinda noob at this.

0

when referencing an object with an if statement the code is just returning a boolean value(true or false) on whether the object is not nil, if the if statement detects true then it runs the code under it

0

Alright, thanks for the explanation

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.