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

How can I make the Explosion apear on the block?

Asked by 1 year ago

I wanted to make it that when an Object with an specific name (in this case BallBall) will touch the Part with the script in it, the Part with the script will explode. But I can not get the right possition of the Explosion. I want the explosion to happen inside or ontop of the Part with the script in it. btw I dont want the Part with the script to be destroyed I want it to explode infinite times.

script.Parent.Touched:Connect(function(Part)
    if Part.Name == "BallBall" then

        local explosion = Instance.new("Explosion")
        explosion.Parent = script.Parent
        explosion.Parent = script.Parent.CFrame   <--  This is the Part im struggling with.
        explosion.BlastRadius = 14
        explosion.BlastPressure = 5000
    end
end)

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

In Line 6 you typed: explosion.parent = script.parent.CFrame and not explosion.Position = script.parent.Position. Also, you want it to explode infinity? make sure you use while wait(0.2) do

script.Parent.Touched:Connect(function(Part)
    if Part.Name == "BallBall" then
        while wait(0.2) do --- While wait() do prevents the game from breaking
            local explosion = Instance.new("Explosion")
            explosion.Parent = script.Parent
            explosion.Position = script.Parent.Position
            explosion.BlastRadius = 14
            explosion.BlastPressure = 5000
        end
    end
end)

However, you can use these as well:

script.Parent.Touched:Connect(function(Part)
    if Part.Name == "BallBall" then
        while true do
            local explosion = Instance.new("Explosion")
            explosion.Parent = script.Parent
            explosion.Position = script.Parent.Position
            explosion.BlastRadius = 14
            explosion.BlastPressure = 5000
            wait()
        end
    end
end)
Ad

Answer this question