#"Gate" Disappearing from Workspace

2 messages · Page 1 of 1 (latest)

gleaming cloak
#

Code Executed when GUI Button is Pressed: (Located in StarterGUI, Type: 'Local Script')

elevatorSwitch.lockButton.MouseButton1Click:Connect(function()    
    game.ReplicatedStorage.elevatorLockdown:FireServer("Lock")
    
    local cdTimer = 1
    local deployTimer = false
    
    elevatorSwitch.lockButton.Visible = false
    elevatorSwitch.cooldownFrame.Visible = true
    deployTimer = true
    
    
    while deployTimer == true do
        elevatorSwitch.cooldownFrame.cooldownTimer.Text = cdTimer.."s"
        wait(1)
        cdTimer -= 1

        if cdTimer == 0 then
            wait(1)
            elevatorSwitch.cooldownFrame.Visible = false
            elevatorSwitch.unlockButton.Visible = true
            cdTimer = 1
            deployTimer = false
        end
    end
end)


elevatorSwitch.unlockButton.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.elevatorLockdown:FireServer("Unlock")
    
    local cdTimer = 1
    local deployTimer = false

    elevatorSwitch.unlockButton.Visible = false
    elevatorSwitch.cooldownFrame.Visible = true
    deployTimer = true


    while deployTimer == true do
        elevatorSwitch.cooldownFrame.cooldownTimer.Text = cdTimer.."s"
        wait(1)
        cdTimer -= 1

        if cdTimer == 0 then
            wait(1)
            elevatorSwitch.cooldownFrame.Visible = false
            elevatorSwitch.lockButton.Visible = true
            cdTimer = 1 --Restore to orignal value when done debugging, same goes for upper value
            deployTimer = false
        end
    end
end)
#

Server Response for the Remote Event Triggered: (Located in ServerScriptService, Type: 'Server Script')

game.ReplicatedStorage.elevatorLockdown.OnServerEvent:Connect(function(_, act)
    local gate = game.Workspace:FindFirstChild("elevatorGate")
    if not gate then
        warn("Gate not found in Workspace")
        return
    end

    if act == "Lock" then
        wait(1)
        print("Locked")
        gate.Transparency = 0
        gate.CanCollide = true
        --[[
        for i, v in pairs(gate) do
            if v:IsA("BasePart") then
                v.Transparency = 0
                v.CanCollide = true
            end
        end
        ]]
        workspace.elevatorLight.Color = Color3.fromRGB(255, 0, 0)
        workspace.elevatorLight.SpotLight.Color = Color3.fromRGB(255, 0, 0)
    elseif act == "Unlock" then
        wait(1)
        print("Unlocked")
        gate.Transparency = 1
        gate.CanCollide = false
        --[[
        for i, v in pairs(gate) do
            if v:IsA("BasePart") then
                v.Transparency = 1
                v.CanCollide = false
            end
        end
        ]]
        workspace.elevatorLight.Color = Color3.fromRGB(47, 255, 0)
        workspace.elevatorLight.SpotLight.Color = Color3.fromRGB(47, 255, 0)
    end
end)