I want to make script for bonfire which will light a player character but always get problem Workspace.Part.FIRE:5: attempt to index nil with 'Parent'
Here is my script:
local bon = script.Parent
local function onTouch(hit)
local hum = hit.Parent.Parent:FindFirstChild ("Humanoid") -- here is problem
if hum then
local Fire = Instance.new ("Fire", hit)
Fire.name = "Fire"
Fire.Enabled = true
local Firedmg = 2
while Fire.Enabled and hum.Health > 0 do
wait (0.3)
hum:TakeDamage (Firedmg)
Firedmg = Firedmg + 0.5
end
local Firedmg = 2
end
end
bon.Touched:Connect(onTouch())

1 comment
It is redundant to rename Fire as Fire because it's the default name. Also, the correct capitalization is "Name" not name.