Local Script:
local PointLight = game.Workspace.Lamp.Union.PointLight
local battery = 60
local lamp = game.Workspace.Lamp.Union
local timer = script.Parent.Timer
while true do
wait()
if PointLight.Enabled == true then
battery = battery - 1
print(battery)
timer.Text = battery
wait(1)
end
if battery == 1 then
timer.Text = 0
print("Lamp Break")
lamp.PointLight:Destroy()
lamp.Break:Play()
lamp.Script.Disabled = true
lamp.Material = 'Sand'
lamp.Script:Destroy()
wait(0.1)
break
end
end
Script That I Destroy:
local battery = 100
function onClicked()
if battery ~= 0 then
if script.Parent.PointLight.Enabled == false then
script.Parent.Sound:Play()
script.Parent.PointLight.Enabled = true
script.Parent.Material = 'Neon'
elseif script.Parent.PointLight.Enabled == true then
script.Parent.Sound:Play()
script.Parent.PointLight.Enabled = false
script.Parent.Material = 'Sand'
end
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)

1 comment
I am not a scripting god so i don't know but does the upper local script work? not the script you destroy the local script?and in the script you destroy i don't see a Destroy()