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

Why Isn't my part not setting people on fire?

So Im making a tool that whenever a humanoid touches the tool's handle (Or part) It well set them to fire. However It for some reason doesn't set It on fire

Here Is the script (NOTE: This script Is added Inside of the handle Itself)

script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:WaitForChild("Humanoid") then
		local char = Hit.Parent
		local fire = Instance.new("Fire")
		fire.Position = char.HumanoidRootPart
	end
end)

2 answers

✓ Accepted answer

You should probably use findFirstChild() instead of waitForChild() because if the part that touches it will never have a humanoid, it will just keep waiting for one that will never be there. Also, when you use Instance.new() with only one argument, the new instance does not have a parent yet. You can use the 2nd argument of Instance.new() which lets you decide what the fire's parent will be. Lastly, Position isn't a property of fire, if I were you, I'd just make the fire a child of the humanoidRootPart:

script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		local char=Hit.Parent.HumanoidRootPart
		local fire = Instance.new("Fire",char)
	end
end)

2 comments

0

Thanks!

0

No problem!

To find whether hit.Parent has a humanoid, you use FindFirstChild()

script.Parent.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        local char = Hit.Parent
        local fire = Instance.new("Fire")
        fire.Position = char.HumanoidRootPart
    end
end)

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