I finally got somewhere with making a car explode for my Game, however when I hit any of the 120 bricks (Walls) it won't run the script. Could anybody help me out here?
debounce = false S = script.Parent script.Parent.Touched:connect(function(Explode) if debounce == true then return end debounce = true if Explode.Parent.Parent.Parent:FindFirstChild("Wall") then S.Fire.Enabled = true S.Smoke.Enabled = true wait(4) S.Parent.Sound:Play() e = Instance.new("Explosion") e.Parent = S e.Position = S.Position e.BlastRadius = 10 e.BlastPressure = 5000000 S.Fire:Destroy() S.Smoke:Destroy() S.Parent.VehicleSeat.MaxSpeed = 0 S.Parent.VehicleSeat.Torque = 0 S.Parent.VehicleSeat.TurnSpeed = 0 debounce = false end end)
Okay, I made an edit. See if this works.
debounce = false S = script.Parent script.Parent.Touched:connect(function(Explode) if debounce == true then return end debounce = true for i, v in pairs(Explode.Parent.Parent.Parent:GetChildren()) do -- We look for each part within the parent using GetChildren if v.Name == "Wall" then -- If it has a name called Wall then.. S.Fire.Enabled = true S.Smoke.Enabled = true wait(4) S.Parent.Sound:Play() e = Instance.new("Explosion") e.Parent = S e.Position = S.Position e.BlastRadius = 10 e.BlastPressure = 5000000 S.Fire:Destroy() S.Smoke:Destroy() S.Parent.VehicleSeat.MaxSpeed = 0 S.Parent.VehicleSeat.Torque = 0 S.Parent.VehicleSeat.TurnSpeed = 0 debounce = false end end end)