I want to make it so when you hold down the Button for a Flashlight, the Power percentage drops from 100, but the Script breaks when I try this in the main function:
mouse.KeyDown:connect(function(key) if string.byte(key) == 50 then L.Enabled = true while wait(3) do game.Lighting.PValue.Value = game.Lighting.PValue.Value - 1 end end end)
The script inside the GUI:
while true do script.Parent.Text = game.Lighting.PValue.Value end
mouse.KeyDown:connect(function(key) if string.byte(key) == 50 then L.Enabled = true while wait(3) do game.Lighting.PValue.Value = game.Lighting.PValue.Value - 1 end end end)
This is the script with the main error, a while loop needs a wait(), therefore I have changed true to wait().
while wait() do script.Parent.Text = game.Lighting.PValue.Value end