if HasBat.Value == true then
local BatVal = script.Parent.Parent:FindFirstChild("BatInUse").BatteryPercent
Lightson = true
for _, model in pairs(script.Parent.Parent:GetDescendants()) do
if model:IsA("Model") and model.Name == "HeadLights" then
warn("found another model called headlights")
for _, partInModel in pairs(model:GetDescendants()) do
if partInModel:IsA("BasePart") and partInModel.Name == "Light" then
print("turning part to neon", partInModel)
if partInModel.Material == Enum.Material.Neon then
partInModel.Material = Enum.Material.Plastic
partInModel.SurfaceLight.Enabled = false
Lightson = false
else
partInModel.Material = Enum.Material.Neon
partInModel.SurfaceLight.Enabled = true
end
end
while Lightson == true and BatVal.Value > 0 do
task.wait(0.05)
BatVal.Value = BatVal.Value - 1
if BatVal.Value == 0 then
Lightson = false
partInModel.Material = Enum.Material.Plastic
partInModel.SurfaceLight.Enabled = false
end
end
end
end
end
end
end)
This script slowly depletes a battery while the lights are on, but it does it for 1 light, then does it for the next. how do i do it for both lights at once?