My flashlight Battery GUI doesn't work.
player = script.Parent.Parent.Parent char = player.Character battery = script.Battery -- Starts at 100. light = char.Flashlight.Handle.SpotLight function batteryLife() if light.Enabled == true then repeat wait(1) battery.Value = battery.Value - 1 -- Goes down by 1 every second. until battery.Value == 0 end script.Parent["Battery Frame"].%Battery.%Battery.Value = "Battery:".. battery.Value.. "%" end char.Flashlight.Activated:connect(batteryLife)
No part of this script works.
EDIT: Still doesn't work. Is there anything else that can be added/fixed?
This also looks broken to me.
repeat until battery.Value == 0
Repeat is supposed to be used in this way:
repeat --do stuff until [bool]
I think you forgot to call the function
This should work.
player = script.Parent.Parent.Parent char = player.Character battery = script.Battery -- Starts at 100. light = char.Flashlight.Handle.SpotLight function batteryLife() if light.Enabled == true then repeat wait(1) battery.Value = battery.Value - 1 -- Goes down by 1 every second. until battery.Value == 0 end script.Parent["Battery Frame"].Battery.Battery.Value = "Battery:".. battery.Value .. "%" -- This line caused problems, if the name of whatever you access ACTUALLY has % signs in it, you do it for example like game.Workspace["%battery"].lol Use a format like that end char.Flashlight.Activated:connect(batteryLife)