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)
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)
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)