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!
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.
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()