localscript:
local plr = game.Players.LocalPlayer
local frame = plr.PlayerGui.ControlUI.MainFrame
local lightbutton = frame.LightButton
local options = lightbutton.Frame
local onB = options.On
local offB = options.Off
local auto = options.Auto
local AutomaticActive = false
local AutoOn = false
onB.MouseButton1Click:Connect(function()
local lightsfolder = game.Workspace.Lights
game.ReplicatedStorage["LightEditClient-Server"]:FireServer("on")
for i = 1, 4 do
local currentroof = lightsfolder:FindFirstChild("Roof" .. i)
currentroof.part.BGG.TextLabel.Text = currentroof.Name
currentroof.part.BGG.TextLabel.Visible = true
wait(0.2)
end
for e = 1, 14 do
local currentled = lightsfolder:FindFirstChild("LEDStrip" .. e)
currentled.Main.LED.BBG.TextLabel.Text = currentled.Name
currentled.Main.LED.BBG.TextLabel.Visible = true
wait(0.2)
end
end)
offB.MouseButton1Click:Connect(function()
game.ReplicatedStorage["LightEditClient-Server"]:FireServer("off")
local lightsfolder = game.Workspace.Lights
for i = 1, 4 do
local currentroof = lightsfolder:FindFirstChild("Roof" .. i)
currentroof.part.BGG.TextLabel.Visible = false
wait(0.2)
end
for e = 1, 14 do
local currentled = lightsfolder:FindFirstChild("LEDStrip" .. e)
currentled.Main.LED.BBG.TextLabel.Visible = false
wait(0.2)
end
end)
auto.MouseButton1Click:Connect(function()
game.ReplicatedStorage["LightEditClient-Server"]:FireServer("auto")
end)
game.ReplicatedStorage["LightEditServer-Client"].OnClientEvent:Connect(function(roof,LED)
roof.part.BBG.TextLabel.Text = roof.Name
roof.part.BBG.TextLabel.Visible = true
LED.Main.LED.BBG.TextLabel.Text = LED.Name
LED.Main.LED.BBG.TextLabel.Visible = true
end)
serverscript:
game.ReplicatedStorage["LightEditClient-Server"].OnServerEvent:Connect(function(plr, action)
local lightsfolder = game.Workspace.Lights
local AutoOn = true
local AutomaticActive = true
local auto = nil
if action == "on" then
for i = 1, 4 do
local currentroof = lightsfolder:FindFirstChild("Roof" .. i)
print("Turning " .. currentroof.Name .. " on.")
currentroof.part.Material = Enum.Material.Neon
currentroof.part.Light.Enabled = true
currentroof.part.Light.Color = Color3.fromRGB(255, 255, 255)
currentroof.part.BBG.TextLabel.Text = currentroof.Name
currentroof.part.BBG.TextLabel.Visible = true
wait(0.2)
end
for e = 1, 14 do
local currentled = lightsfolder:FindFirstChild("LEDStrip" .. e)
print("Turning " .. currentled.Name .. " on.")
currentled.Main.LED.Material = Enum.Material.Neon
currentled.Main.LED.Beam.Enabled = true
currentled.Main.LED.SurfaceLight.Enabled = true
currentled.Main.LED.SurfaceLight.Color = Color3.fromRGB(255, 255, 255)
wait(0.2)
end
elseif action == "off" then
for i = 1, 4 do
local currentroof = lightsfolder:FindFirstChild("Roof" .. i)
print("Turning " .. currentroof.Name .. " off.")
currentroof.part.Material = Enum.Material.Plastic
currentroof.part.Light.Enabled = false
currentroof.part.BBG.TextLabel.Visible = false
wait(0.2)
end
for e = 1, 14 do
local currentled = lightsfolder:FindFirstChild("LEDStrip" .. e)
print("Turning " .. currentled.Name .. " off.")
currentled.Main.LED.Material = Enum.Material.Plastic
currentled.Main.LED.Beam.Enabled = false
currentled.Main.LED.SurfaceLight.Enabled = false
wait(0.2)
end
elseif action == "auto" then
local auto = plr.PlayerGui.ControlUI.MainFrame.LightButton.Frame.Auto
auto.Text = "Turn off Automatic"
while AutoOn == true do
local selectedLEDStrips = {}
local selectedRoofLights = {}
for _ = 1, 9 do
local RoofLightSelected = lightsfolder:FindFirstChild("Roof" .. math.random(1, 4))
local LEDStripSelected = lightsfolder:FindFirstChild("LEDStrip" .. math.random(1, 14))
game.ReplicatedStorage["LightEditServer-Client"]:FireClient(plr,RoofLightSelected,LEDStripSelected)
if LEDStripSelected then
selectedLEDStrips[#selectedLEDStrips + 1] = LEDStripSelected
end
if RoofLightSelected then
selectedRoofLights[#selectedRoofLights + 1] = RoofLightSelected
end
end
for _, LEDStripSelected in pairs(selectedLEDStrips) do
local TurnOn = math.random() > 0.5
if TurnOn == false then
LEDStripSelected.Main.LED.Material = Enum.Material.Plastic
print("Setting material to Plastic for " .. LEDStripSelected.Name)
LEDStripSelected.Main.LED.BBG.TextLabel.Visible = false
else
LEDStripSelected.Main.LED.Material = Enum.Material.Neon
print("Setting material to Neon for " .. LEDStripSelected.Name)
LEDStripSelected.Main.LED.BBG.TextLabel.Visible = true
LEDStripSelected.Main.LED.BBG.TextLabel.Text = LEDStripSelected.Name
end
LEDStripSelected.Main.LED.Beam.Enabled = TurnOn
print("Setting Beam.Enabled to " .. tostring(TurnOn) .. " for " .. LEDStripSelected.Name)
LEDStripSelected.Main.LED.SurfaceLight.Enabled = TurnOn
print("Setting SurfaceLight.Enabled to " .. tostring(TurnOn) .. " for " .. LEDStripSelected.Name)
end
for _, RoofLightSelected in pairs(selectedRoofLights) do
local TurnOn = math.random() > 0.5
if TurnOn == false then
RoofLightSelected.part.Material = Enum.Material.Plastic
RoofLightSelected.part.BBG.TextLabel.Visible = false
else
RoofLightSelected.part.Material = Enum.Material.Neon
RoofLightSelected.part.BBG.TextLabel.Visible = true
RoofLightSelected.part.BBG.TextLabel.Text = RoofLightSelected.Name
end
RoofLightSelected.part.Light.Enabled = true
end
wait(0.87)
end
print("Automatic mode activated")
else
AutomaticActive = false
AutoOn = false
auto.Text = "Start Automatic"
print("Automatic mode deactivated")
end
end)
When the on
button is clicked. It is supposed to change the part/light (and edit it properites) works. and then show the text only to the person that clicks the button the main problem
Another problem is the fact that the ledstrip text is decided to just not appear (even know it does on the automatic mode)