Help with debugging/rewriting a script with a circle that increases in size and stops

This is my first DevForum post. Aside from that, I need some help with writing this script, as I can’t locate the issue and figure how to rewrite the code correctly/debug it.

local thing = script.Parent
local explosion = thing.Explosion
explosion.Transparency = 0
local isActive = false

local function combust()
	if not isActive then
		isActive = true
		task.wait(3)
		for count = 1,10 do
			explosion.Transparency = count / 10
			explosion.Size = count.Vector3(1,1,1)
			task.wait(0.1)
		end
		explosion.Transparency = 0
		explosion.Size = explosion.Size.Vector3(1.957,1.957,1.957)
		task.wait(3)
		isActive = false
	end
end

combust()

Here are the issues:

For context, my model called “Thing” has a script with another part called “Explosion” in it. I’m trying to make the explosion increase in size and decrease in transparency (which is successful) but the “explosion” part is not increasing in size and I can’t figure out how to debug the code or rewrite the vector3, etc for line 12. This also applies to line 16, however hasn’t received an error yet as I haven’t figured out to debug line 12 yet and both of them need potential rewriting.

Can someone please help debug the code for me, maybe even improve the code? Thank you!

2 Likes

For additional context (which I forgot to include in my original post), what I’m trying to get debugged is the “Explosion” part increasing in size, which then after 3 seconds, the “Explosion” part returns to it’s original size and transparency. This includes line 12 and 16.

The problem with your script is here:

“count” is a number between 1 and 10. It seems like you want to multiply the number by the size of the explosion part and set the size to that?

If so, do this:

explosion.Size = explosion.Size * Vector3.new(count, count, count)

This should work. If it does, please mark it as solution. If it doesn’t please let me know!

Also, you should change this:

to this:

explosion.Size = Vector3.new(1.957, 1.957, 1.957)

Tried it but the “explosion” part doesn’t increase in size at all or activate the “for count 1,10 do”.

Did you replace explosion.Size = count.Vector3(1,1,1) with the line I sent?

I tried it, but it showed no error and simply didn’t explode at all.

Try printing the count in the for loop.


It shows the print, but Line 12/13 does not seem to work. Nor does the transparency decreases or size increases.

Can I see your layout in Explorer?

thething5
This is the layout of the model I’m trying to get debugged. Unless you are talking about the entire workspace, that is.

Note: The Explosion part should be welded to Thing so that its always centered in the same position as it.

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)

local thing = script.Parent
local explosion = thing.Explosion
explosion.Transparency = 0
local isActive = false

local originalSize = explosion.Size
local sizeMultiplier = 2

local explosionTween = TweenService:Create(explosion, tweenInfo, {
	Size = originalSize * sizeMultiplier,
	Transparency = 0
})

local function combust()
	if not isActive then
		isActive = true
		task.wait(3)
		explosionTween:Play()
		task.wait(3)
		isActive = false
		explosion.Transparency = 1
		explosionTween.Size = originalSize
	end
end

combust()

Does this code work?

Tried it, but this was the result.


Not much really changed.

Make sure to make these checks:

  • Explosion is unanchored.
  • Explosion has a Weld under it that keeps it attached to Thing.

If you don’t know how to weld stuff, then just overwrite the code to this:

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)

local thing = script.Parent
local explosion = thing.Explosion
explosion.Transparency = 0
local isActive = false

local weld = Instance.new("Weld")
weld.Part0 = explosion
weld.Part1 = thing
weld.Parent = explosion

local originalSize = explosion.Size
local sizeMultiplier = 2

local explosionTween = TweenService:Create(explosion, tweenInfo, {
	Size = originalSize * sizeMultiplier,
	Transparency = 0
})

local function combust()
	if not isActive then
		isActive = true
		task.wait(3)
		explosionTween:Play()
		task.wait(3)
		isActive = false
		explosion.Transparency = 1
		explosion.Size = originalSize
	end
end

combust()

Tried it but now there’s an error. Even without weld.

My apologies, I made a mistake within the code, I corrected it with an edit, can you try copy pasting the code again?

I copy and pasted the code. There’s no error, but the size or transparency does not appear to change at all.

Is Explosion in the middle of the “Thing” part?

What do you mean by that? I don’t quite understand what you are saying.

When pressing Play, and clicking on the Explosion part, is it where it’s supposed to be?