im kind of new to coding and cant seem to figure this out, i want it so when my health reaches 0 (dies) the lava stops moving up, but instead it keeps on moving
local distance = 0
local enabled = true
local originalPosition = game.Workspace.Lava.CFrame
game.Workspace.Lava.Touched:Connect(function(PlayerWhoTouched)
if enabled then
local character = PlayerWhoTouched.Parent
local humanoid = character and character:FindFirstChild("Humanoid")
if PlayerWhoTouched.Name == "LeftFoot" or PlayerWhoTouched.Name == "RightFoot" then
if humanoid then
humanoid.Health = 0
enabled = false
wait(1)
game.Workspace.Lava.CFrame = originalPosition
end
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
distance = 1000
if enabled == true then
for i = 0, distance do
wait(0.001)
game.Workspace.Lava.CFrame = game.Workspace.Lava.CFrame + Vector3.new(0, 0.1, 0)
wait()
end
end
end)
what is wrong with it?