I created this script and it does not work and I am not sure why. Please feel free to make this smaller if you are confident it will work and please help me find my error.

local L1 = workspace.Light1
local L2 = workspace.Light2
local L3 = workspace.Light3
local L4 = workspace.Light4
local L5 = workspace.Light5
local L6 = workspace.Light6
local L7 = workspace.Light7
local L8 = workspace.Light8
local d1 = workspace.Door1
local d2 = workspace.Door2
local d3 = workspace.Door3
local P = workspace.Plat
local But = workspace.Button
local s = workspace.Screen
game.Players.PlayerAdded:connect(function(player)
	local s = Instance.new("ScreenGui")
	s.Parent = player.PlayerGui
	wait(.1)
	local t = Instance.new("TextBox")
	t.Parent = player.PlayerGui.ScreenGui
	wait(.1)
	player.PlayerGui.ScreenGui.TextBox.FontSize = "Size36"
	player.PlayerGui.ScreenGui.TextBox.Size = UDim2.new(0, 1100,0, 100)
	player.PlayerGui.ScreenGui.TextBox.BackgroundTransparency = 1
	player.PlayerGui.ScreenGui.TextBox.TextTransparency = 1
	player.PlayerGui.ScreenGui.TextBox.Text = "Evacuate to sector J Immediatly!"
	player.PlayerGui.ScreenGui.TextBox.TextColor3 = Color3.new(255/255, 85/255, 0/255)
	player.PlayerGui.ScreenGui.TextBox.BorderColor3 = Color3.new(255/255, 255/255, 0/255)
	player.PlayerGui.ScreenGui.TextBox.BackgroundColor3 = Color3.new(0/255, 0/255, 0/255)
	player.PlayerGui.ScreenGui.TextBox.BorderSizePixel = 10
	
end)

function onClick()
	But.ClickDetector:Remove()
	s.SurfaceGui.TextBox.Text = "Lockdown In Progress"
	s.SurfaceGui.TextBox.TextColor3 = Color3.new(255, 0, 0)
	game.ServerScriptService.Dublicate.Disabled = true
	game.workspace.Sound:Play()
	wait(3)
	L1.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L2.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L3.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L4.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L5.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L6.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L7.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L8.SurfaceLight.Color = Color3.new(255, 0, 0) 
	L1.SurfaceLight.Brightness = 10
	L2.SurfaceLight.Brightness = 10
	L3.SurfaceLight.Brightness = 10
	L4.SurfaceLight.Brightness = 10
	L5.SurfaceLight.Brightness = 10
	L6.SurfaceLight.Brightness = 10
	L7.SurfaceLight.Brightness = 10
	L8.SurfaceLight.Brightness = 10
	L1.Material = 'Plastic'
	L2.Material = 'Plastic'
	L3.Material = 'Plastic'
	L4.Material = 'Plastic'
	L5.Material = 'Plastic'
	L6.Material = 'Plastic'
	L7.Material = 'Plastic'
	L8.Material = 'Plastic'
	L1.BrickColor = BrickColor.new("Really red")
	L2.BrickColor = BrickColor.new("Really red")
	L3.BrickColor = BrickColor.new("Really red")
	L4.BrickColor = BrickColor.new("Really red")
	L5.BrickColor = BrickColor.new("Really red")
	L6.BrickColor = BrickColor.new("Really red")
	L7.BrickColor = BrickColor.new("Really red")
	L8.BrickColor = BrickColor.new("Really red")
	game.workspace.Sound:Pause()
	game.workspace.sound:Play()
	wait(10)
	game.workspace.sound:Pause()
	game.workspace.Door:Play()
	wait(3)
	d3.CFrame = CFrame.new(87.5, -6, 25.5)
	d2.CFrame = CFrame.new(87.5, 8.5, -82.5)
	d1.CFrame = CFrame.new(31.5, 8.5, -78.5)
	wait(3)
	game.workspace.Door:Pause()
	game.workspace.Evac:Play()
	wait(10)
	game.workspace.Evac:Pause()
	game.workspace.Music:Play()
	wait(115)
	game.workspace.Music:Pause()
	game.workspace.Alarm:Play()
	wait(5)
	game.workspace.Destruct:Play()
	wait(3)
	game.workspace.Destruct:Pause()
	game.workspace.Emerge:Play()
	wait(5)
	game.workspace.Emerge:Pause()
	P.CFrame = CFrame.new(149, 19.5, -318.5)
	game.workspace.D.Script.Disabled = true
	game.workspace.D.CanCollide = true
	
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.BackgroundTransparency = 0
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.TextTransparency = 0
	wait(5)
	game.workspace.Alarm:Pause()
	game.workspace.Zap:Play()
	L1.SurfaceLight.Brightness = 0
	L2.SurfaceLight.Brightness = 0
	L3.SurfaceLight.Brightness = 0
	L4.SurfaceLight.Brightness = 0
	L5.SurfaceLight.Brightness = 0
	L6.SurfaceLight.Brightness = 0
	L7.SurfaceLight.Brightness = 0
	L8.SurfaceLight.Brightness = 0
	wait(5)
	game.workspace.Zap:Pause()
	game.workspace.Zap:Play()
	L1.SurfaceLight.Brightness = 10
	L2.SurfaceLight.Brightness = 10
	L3.SurfaceLight.Brightness = 10
	L4.SurfaceLight.Brightness = 10
	L5.SurfaceLight.Brightness = 10
	L6.SurfaceLight.Brightness = 10
	L7.SurfaceLight.Brightness = 10
	L8.SurfaceLight.Brightness = 10
	game.workspace.Zap:Pause()
	game.workspace.Alarm:Play()
	wait(10)
	game.workspace.Alarm:Pause()
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Board sector J's elevator now!"
	local gg = Instance.new("Sound")
	gg.SoundId = "http://www.roblox.com/asset/?id=148264684"
	gg.Parent = game.Workspace
	gg.Volume = 1
	gg:Play()
	wait(6.5)
	gg:Pause()
	gg:Remove()
	game.workspace.C:Play()
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Elevator leaving in 5"
	wait(1)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Elevator leaving in 4"
	wait(1)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Elevator leaving in 3"
	wait(1)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Elevator leaving in 2"
	wait(1)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Elevator leaving in 1"
	wait(1)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Elevator left, If your left behind..."
	game.workspace.C:Pause()
	wait(2)
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "You will die."
	wait(2)
	game.Workspace.Final:Play()
	L1.SurfaceLight.Brightness = 0
	L3.SurfaceLight.Brightness = 0
	L4.SurfaceLight.Brightness = 0
	L6.SurfaceLight.Brightness = 0
	L8.SurfaceLight.Brightness = 1
	wait(20)
	for I = 60,1,-1 do 
	game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = I 
	wait(1) -- There you go
	end
	if game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text == 10 then
		game.Workspace.Count:Play()
		wait(10)
		game.Workspace.Count:Pause()
		wait(1)
		
	end
	if game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text == 1 then
		
		game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Text = "Game must be rebuilt!"
	end 
	wait(10)
	
Players = game.Players:GetChildren() --Gets a table of all the players
for i=1,#Players do --Sets a loop to go through all the players
	
    if Players[i].Character then --Finds if their character is existant
        Player.Character.Humanoid.Health = 0 --Sets health to 0 (Kills)
    end
end
end
But.ClickDetector.MouseClick:connect(onClick)

1 comment

0

Does it produce any output? What did you expect, and what happened?