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 2 years 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.

01script.Parent.Touched:Connect(function(Part)
02    if Part.Name == "BallBall" then
03 
04        local explosion = Instance.new("Explosion")
05        explosion.Parent = script.Parent
06        explosion.Parent = script.Parent.CFrame   <--  This is the Part im struggling with.
07        explosion.BlastRadius = 14
08        explosion.BlastPressure = 5000
09    end
10end)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years 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

01script.Parent.Touched:Connect(function(Part)
02    if Part.Name == "BallBall" then
03        while wait(0.2) do --- While wait() do prevents the game from breaking
04            local explosion = Instance.new("Explosion")
05            explosion.Parent = script.Parent
06            explosion.Position = script.Parent.Position
07            explosion.BlastRadius = 14
08            explosion.BlastPressure = 5000
09        end
10    end
11end)

However, you can use these as well:

01script.Parent.Touched:Connect(function(Part)
02    if Part.Name == "BallBall" then
03        while true do
04            local explosion = Instance.new("Explosion")
05            explosion.Parent = script.Parent
06            explosion.Position = script.Parent.Position
07            explosion.BlastRadius = 14
08            explosion.BlastPressure = 5000
09            wait()
10        end
11    end
12end)
Ad

Answer this question