Hi, I'm trying to make a fire sword and when it it activated on the second time, it will make the opponent burn. This is the the burning script in the firesword tool:
local cool = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and cool == false and hit.Parent ~= script.Parent.Parent.Parent then
if hit.Parent.Humanoid.Health > 0 then
cool = true
if game.ServerStorage:FindFirstChild("Burn")then
local burn = game.ServerStorage.Burn:Clone()
burn.Parent = hit
burn.Disabled = false
if burn ~= nil then
wait()
if hit.Parent.Humanoid.Health == 0 then
local name = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent)
if name:FindFirstChild("leaderstats")then
name.leaderstats.Kills.Value = name.leaderstats.Kills.Value + 1
name.leaderstats.Coins.Value = name.leaderstats.Coins.Value + 1
end
end
end
end
script.Disabled = true
cool = false
end
end
end)
This will duplicate a burning script in my ServerStorage and send it to the hit part. here is the script:
while script ~= nil do
wait(0.1)
local check = script.Parent.Parent:FindFirstChild("Humanoid") -- 'Attempt to index nil with Parent 'error here
if check then
if script.Parent.Parent.Humanoid.Health > 0 then
cool = true
local wa = Instance.new("Fire")
wa.Parent = script.Parent
for i = 1,5 do
script.Parent.Parent.Humanoid.Health = script.Parent.Parent.Humanoid.Health - 10
wait(1)
end
wa:Destroy()
script:Destroy()
cool = false
end
end
end
Please help me fix this error. Thank you!
