Hello everyone! I’m making lava that rises, but I want to make it whenever you die the lava goes back to its original size. Here’s the lava’s script:
local tweenService = game:GetService("TweenService")
local greenLava = script.Parent
local tweenInfo = TweenInfo.new(13, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local tweenGoal = {Size = Vector3.new(273.7, 78.60, 252.56)}
if greenLava:WaitForChild("LavaStart") then
greenLava:WaitForChild("LavaStart"):Destroy()
local tweenAnim = tweenService:Create(greenLava, tweenInfo, tweenGoal)
tweenAnim:Play()
greenLava.Touched:Connect(function(hit)
local hooman = hit.Parent:FindFirstChild("Humanoid")
hooman.Health = 0
end)
end
Are there any methods I can use to reset the lava’s size whenever the player dies? Thank you for reading!
Wouldn’t storing the original size as a variable then setting it back to that value after hooman.Health = 0 has been executed work?
i.e
local tweenService = game:GetService("TweenService")
local greenLava = script.Parent
local tweenInfo = TweenInfo.new(13, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local tweenGoal = {Size = Vector3.new(273.7, 78.60, 252.56)}
local originalSize = Vector3.new(0,0,0) -- Obviously, original size and not 0,0,0
if greenLava:WaitForChild("LavaStart") then
greenLava:WaitForChild("LavaStart"):Destroy()
local tweenAnim = tweenService:Create(greenLava, tweenInfo, tweenGoal)
tweenAnim:Play()
greenLava.Touched:Connect(function(hit)
local hooman = hit.Parent:FindFirstChild("Humanoid")
hooman.Health = 0
tweenAnim:Stop()
greenLava.Size = originalSize
tweenAnim:Play()
end)
end