i am using a variable as my wait time in my script and if i change the variable while the loops is running the wait time will stay the same here is my script
local wa = game.Workspace.UniBeams2.UI.Pages.Page1.Speed.Intensity.Value.Value * -0.035 + 0.5
while wait() do
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U1”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U2”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U3”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U4”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U5”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U6”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U7”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U8”
then
v.LightingController.Pan:Invoke(-45)
end
end
wait(wa)
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U1”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U2”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U3”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U4”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U5”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U6”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U7”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U8”
then
v.LightingController.Tilt:Invoke(45)
end
end
wait(wa)
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U1”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U2”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U3”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U4”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U5”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U6”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U7”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U8”
then
v.LightingController.Pan:Invoke(45)
end
end
wait(wa)
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U1”
then
v.LightingController.Tilt:Invoke(135)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U2”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U3”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U4”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U5”
then
v.LightingController.Pan:Invoke(-45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U6”
then
v.LightingController.Tilt:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U7”
then
v.LightingController.Pan:Invoke(45)
end
end
for i,v in pairs (game.Workspace.Ulights:GetChildren())
do
if v.Name == “U8”
then
v.LightingController.Tilt:Invoke(135)
end
end
wait(wa)
end