Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to make a brick explode when it touches the object. Help?

Asked by 6 years ago
Edited 6 years ago

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)
0
just add sn if statement abnotaddable 920 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

0
Now it just doesn't explode at all. ShadowNinja1080 6 — 6y
0
ok try now. but i have no idea why it didn't work before. maybe you misspelled something? RiskoZoSlovenska 378 — 6y
Ad

Answer this question