Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I make the Explosion apear on the block?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.