hello im trying to make a notification that tellls the player there are flashing lights and it gives them to option to turn it off.
im creating a new folder inside of player with the values 1,2 which tell the lights to flash or not.
im trying to change that value inside of the textbutton when clicked.
- heres the scripts:
script to button:
local click = false
script.Parent.MouseButton1Click:Connect(function()
local click = not click
if click == true then
game.Players.LocalPlayer.SettingsFolder:WaitForChild("FlickeringLights").Value = 2
script.Parent.Text = "Turned Off"
script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 115)
elseif click == false then
game.Players.LocalPlayer.SettingsFolder:WaitForChild("FlickeringLights").Value = 1
script.Parent.Text = "Turned On"
script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
end
end)
script to the value creator located in scriptstorage
game.Players.PlayerAdded:Connect(function(plr)
local SettingsFolder = Instance.new("Folder")
SettingsFolder.Name = "SettingsFolder"
SettingsFolder.Parent = plr
local FlickeringLights = Instance.new("IntValue")
FlickeringLights.Name = "FlickeringLights"
FlickeringLights.Parent = SettingsFolder
FlickeringLights.Value = 1
end)
end)
script to lights
local light = script.Parent.PointLight
local part = script.Parent
local disabled = light.Brightness
local Light = light.Range
if game.Players.LocalPlayer.SettingsFolder:WaitForChild("FlickeringLights").Value = 1 then
while true do
wait()
disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
wait(math.random(0.6, 0.8))
disabled = 0 light.Brightness = 0 part.Material = "Glass"
wait(math.random(0.6, 0.8))
disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
wait(math.random(0.6, 0.8))
disabled = 0 light.Brightness = 0 part.Material = "Glass"
wait(math.random(0.6, 0.8))
disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
wait(math.random(1, 3))
disabled = 0 light.Brightness = 0 part.Material = "Glass"
wait(math.random(0.6, 0.8))
disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
wait(math.random(0.6, 0.8))
end