I'm trying to make vehicle when it like gets flipped over, it explodes and the parts along it are caught on fire. So far I made brick and put it on top of the vehicle; however, it explodes when a player touches the brick. How do I make so that it blows up when it touches the ground or the object rather than a humanoid player? Here's my script;
wait (1) function boom() script.Parent.Anchored = true script.Parent.Parent.Gun1.Anchored = true script.Parent.Parent.Gun2.Anchored = true script.Parent.Parent.Engine.Anchored = true wait (0.01) a = Instance.new ("Explosion") a.Parent = Workspace a.Position = script.Parent.Position a.BlastRadius = 10 wait (1) script.Parent.Anchored = false script.Parent.Parent.Gun1.Anchored = false script.Parent.Parent.Gun2.Anchored = false script.Parent.Parent.Engine.Anchored = false b = Instance.new ("Fire") b.Parent = script.Parent b.Size = 10 c = Instance.new ("Fire") c.Parent = script.Parent.Parent.Gun1 c.Size = 10 d = Instance.new ("Fire") d.Parent = script.Parent.Parent.Gun2 d.Size = 10 e = Instance.new ("Fire") e.Parent = script.Parent.Parent.Engine e.Size = 10 wait (0.1) script:remove() end script.Parent.Touched:connect (boom)
Your problem is that it executes the code whenever the brick touches anything. All you need is a simple if
statement that checks if the part that touched is a part of a player. This should help you:
wait (1) function boom() if part.Parent:findFirstChild("Humanoid") ~= nil then return nil else script.Parent.Anchored = true script.Parent.Parent.Gun1.Anchored = true script.Parent.Parent.Gun2.Anchored = true script.Parent.Parent.Engine.Anchored = true wait (0.01) a = Instance.new ("Explosion") a.Parent = Workspace a.Position = script.Parent.Position a.BlastRadius = 10 wait (1) script.Parent.Anchored = false script.Parent.Parent.Gun1.Anchored = false script.Parent.Parent.Gun2.Anchored = false script.Parent.Parent.Engine.Anchored = false b = Instance.new ("Fire") b.Parent = script.Parent b.Size = 10 c = Instance.new ("Fire") c.Parent = script.Parent.Parent.Gun1 c.Size = 10 d = Instance.new ("Fire") d.Parent = script.Parent.Parent.Gun2 d.Size = 10 e = Instance.new ("Fire") e.Parent = script.Parent.Parent.Engine e.Size = 10 wait (0.1) script:remove() end end script.Parent.Touched:connect(boom)
Accept if this helped