Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a door that opens when five lights are activated or neon?

Asked by
Qu_xtty -8
4 years ago
Edited by SerpentineKing 4 years ago
-- Variables
local ActivationLights = game.Workspace.ActivationLights
local DarklightDoor = script.Parent

local function updateDoor()

    local isAllNeon = true
    for _,light in pairs(ActivationLights:GetChildren()) do
        if light.Material ~= Enum.Material.Neon then
            isAllNeon = false
            break
        end
    end

    if isAllNeon then
        DarklightDoor.Transparency = 1
        DarklightDoor.CanCollide = false
    else

    end

end

for _,light in pairs(ActivationLights:GetChildren()) do
    light:GetPropertyChangedSignal("Material"):Connect(updateDoor)
end

Anyways, here is an example of what I'm trying to do. I want the door to become transparent and CanCollide = false when ErnestaLight, DanLight, AquiziviteLIght, LovelyLight, and QuinnKennithLight are neon/activated. Please help! (For a myth game) Before you ask, nothing is underlined, nothing comes out in the output.

0
Didn't you already ask this? DesertusX 435 — 4y
0
Yes, I’ve been trying to get an answer and have been working to find the right code, but I cant. Qu_xtty -8 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
--variables for your lights and door here


local lights = {light1, light2, light3, light4, light5,}

local function Evaluate()
    local doorOpen = true
     for i = 1, #lights do
            if not lights[i].Material == Enum.Material.Neon then
                doorOpen = false
                break
            end
        end

    if doorOpen then
    YourDoor.Cancollide = false
    YourDoor.Transparency = .5 -- or whatever you prefer

    else 
    YourDoor.CanCollide = true
    YourDoor.Tansparency = 0

     end
end

for i = 1, #lights do
    lights[i].Changed:Connect(function()
       Evaluate()
print ("Triggered") -- this was a test, delete it if you like
    end)
end


0
This is the script I made for a similar case in my game, declare your lights and door at the top of the script. It should 'open' your door if ALL five lights are neon aprilsfooled 29 — 4y
0
Look at my answer below Qu_xtty -8 — 4y
Ad
Log in to vote
0
Answered by
Qu_xtty -8
4 years ago
Edited 4 years ago

--variables for your lights and door here

local lights = {game.Workspace.DarklightDoor.AquiziviteLight, game.Workspace.DarklightDoor.DanLight, game.Workspace.DarklightDoor.ErnestaLight, game.Workspace.DarklightDoor.LovelyLight, game.Workspace.DarklightDoor.QuinnKennithLight} local YourDoor = game.Workspace.DarklightDoor

local function Evaluate() local doorOpen = true for i = 1, #lights do if not lights[i].Material == Enum.Material.Neon then doorOpen = false break end end

if doorOpen then
YourDoor.CanCollide = false
YourDoor.Transparency = 1 -- or whatever you prefer

 end

end

for i = 1, #lights do lights[i].Changed:Connect(function() Evaluate() print ("Triggered") -- this was a test, delete it if you like end) end

I changed it to this, why isn't it working?

0
not 100% sure. try local light1 = game.Workspace.DarklightDoor.AquiziviteLight, light2 = .... , .... then your table local lights = {light1, light2, light3, light4, light5,} aprilsfooled 29 — 4y

Answer this question