I am currently making a flood escape type game, but I don’t know how to make the lava reset it’s position when the round ends. All feedbacks are appreciated!
Code:
Lava rise code:
local be = script.Parent
local lava = game.Workspace.Lava
local lavaSpeed = lava:GetAttribute("lavaSpeed")
local function onEvent()
print("Start Lava")
while true do
lava.Size = lava.Size + Vector3.new(0, lavaSpeed, 0)
lava.Position = lava.Position + Vector3.new(0, lavaSpeed/2, 0)
wait(0.1)
end
end
be.Event:Connect(onEvent)
Game timer code:
for i = lavaRise, 0, -1 do
InRound.Value = true
wait(1)
Status.Value = "Lava Rises in ".. i .. " seconds!"
end
be:Fire()
for i = roundLength, 0, -1 do
InRound.Value = true
wait(1)
Status.Value = "Game: ".. i .. " seconds left!"
wait(1)
end
end
end
Have the server fire a RoundEnded event or something that will turn off the lava rise loop, then reset its position.
local lavaSpeed = Vector3.new(0, 1, 0)
local lavaSpeedHalf = lavaSpeed / 2
local roundPlaying = true
RoundEnded:Connect(function()
roundPlaying = false
end)
local function onEvent()
print("Start Lava")
local oldPos = lava.Position
while roundPlaying do
lava.Size += lavaSpeed
lava.Position += lavaSpeedHalf
task.wait(0.1)
end
task.wait(2) -- Buffer time
lava.Position = oldPos
end