I need help with my lockdown script

  1. What do you want to achieve?
    I want to make a lockdown system when an Admin presses the on button doors close, GUI pops up and sound plays.
  2. What is the issue?
    Script won’t work.
  3. What solutions have you tried so far?
    I looked it up on youtube, changed the script, and changed from LocalScript to Script

I’m also new to scripting, so I don’t know much about that stuff.

Here’s the script:

local Door = game.Workspace.DrivingTestDoor
local Door2 = game.Workspace.ObbyDoor
local Door3 = game.Workspace.RangeShooting
local Door4 = game.Workspace.Door
local Door5 = game.Workspace.SpawnDoor

script.Parent.MouseButton1Click:Connect(function()
game.StarterGui.Messages.Lockdown.Lockdown.Visible=true
game.StarterGui["Host Panel"].PanelMobile.ScrollFrame.LockDown["Lockdown alarm"].Playing=true
game.StarterGui["Host Panel"].PanelMobile.ScrollFrame.LockDown["Lockdown alarm"].Looped=true
Door.Transparency=0.7
Door.CanCollide=true
Door2.Transparency=0.7
Door2.CanCollide=true
Door3.Transparency=0.7
Door3.CanCollide=true
Door4.Transparency=0
Door4.CanCollide=true
Door5.Transparency=0.7
Door5.CanCollide=true
end)

Is the script a localscript?

(e)

Im not the greatest at scripting so I am most likely 100% false but I think you need the playergui, not startergui

No, it’s a normal script.

[MoreCharacters]

MouseButton1Clicked only works with localscripts, use a localscript to handle the input and then fire a RemoteEvent.

It worked for this script.

local Door = game.Workspace.Door

script.Parent.MouseButton1Click:Connect(function()
game.Workspace.Door.Status.SurfaceGui.Closed.Visible=false
game.Workspace.Door.Status.SurfaceGui.Open.Visible=true
Door.Transparency=0.7
Door.CanCollide=false
end)

welcome to the scripting support category
i just lost so many braincells reading this post

this is invalid, you cannot change gui over StarterGui because the visible GUI while playing the game, you must use localscripts to be able to do this
you can use RemoteEvents to order LocalScripts to do certain functions by a ServerScript, or vice versa (in replicatedstorage)
create a remoteevent in ReplicatedStorage and name it to whatever you want
add a local script in StarterGui and do the

local replicated = game:GetService("ReplicatedStorage") --yields script until service is found
local event = replicated:WaitForChild("youraverageevent") --yields the script until an instance is found, replace target with name of remoteevent for now
local frame = script.Parent.Messages.Lockdown:WaitForChild("Lockdown")
--OnClientEvent function
event.OnClientEvent:Connect(function() --if a script fires the client then the script will do the following:
  frame.Visible = true --now you "legally" change the visibility of a gui
end)

ok now to the server script

i know you are new to scripting, but there is another way to shorten the length of a script using your brain so it doesn’t consume this much space
but yeah ill just rewrite the script cuz why not

local Doors = {game.Workspace.DrivingTestDoor, game.Workspace.ObbyDoor, game.Workspace.RangeShooting, game.Workspace.Door, game.Workspace.SpawnDoor} --table holds mutple values

script.Parent.MouseButton1Click:Connect(function()
  for c = 1, #Doors do -- repeat a certain number of times
    if c ~= 4 then -- if agurement is met + ~ is an alternative to not
      Doors[c].Transparency = 0.7
    else --if agurement is not met
       Doors[c].Transparency = 0
    end
    Doors[c].CanCollide = true --your orginal script had false, which will allow people to clip through the walls
    wait()
  end
end)

if it doesn’t work, blame my stupidity over this

1 Like

Wow, it worked.
What about the Lockdown sound.

oops i forgo
set the sound looped to true

local replicated = game:GetService("ReplicatedStorage") --yields script until service is found
local event = replicated:WaitForChild("youraverageevent") --yields the script until an instance is found, replace target with name of remoteevent for now
local frame = script.Parent.Messages.Lockdown:WaitForChild("Lockdown")
--OnClientEvent function
event.OnClientEvent:Connect(function() --if a script fires the client then the script will do the following:
  frame.Visible = true --now you "legally" change the visibility of a gui
  script.Parent["Host Panel"].PanelMobile.ScrollFrame.LockDown["Lockdown alarm"]:Play() --play audio
end)
1 Like

Thank you so much, that worked too.

1 Like