Basically, I'm building a nuke where when it detonates it destroys any parts in it's radius, but if it's a player they lose HP. However, it's not working and instead leaves the parts it's supposed to destroy and destroys any parts that it comes in contact afterwards. The error says that I'm attempting to index field parent, because it's a nil value. Any help?
local explosion = Instance.new("Part",workspace) explosion.Position = script.Parent.thing.Position wait(0.1) explosion.Shape = "Ball" explosion.BrickColor = BrickColor.new("Bright green") explosion.Material = "Foil" explosion.CanCollide = false explosion.Anchored = true explosion.Transparency = 0.25 for i = 5,0,-1 do explosion.Size = explosion.Size * 2 wait(0.3) explosion.Touched:Connect(function(touch) if touch.Parent:FindFirstChild("Humanoid") then touch.Parent.Humanoid:TakeDamage(100) else touch:Destroy() end end) end script.Parent.Nuke:Destroy()
local explosion = Instance.new("Part") explosion.Shape = "Ball" explosion.BrickColor = BrickColor.new("Bright green") explosion.Material = "Foil" explosion.CanCollide = false explosion.Anchored = true explosion.Transparency = 0.25 explosion.Position = script.Parent.thing.Position wait(0.1) for i = 1, 5 do explosion.Size = explosion.Size * 2 explosion.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(100) else hit:Destroy() end end wait(0.3) end) script.Parent.Nuke:Destroy()
i don't see anything wrong, by the way @mattscy after line 19 it will still work because of line 15.