Slock script won't work

Hello!
I wrote the slock script below:

local Events = script.Parent:WaitForChild('Events')
local Slock = Events:WaitForChild('Slock')
local Config = require(script.Parent:WaitForChild('Configuration'))
local Players = game:GetService('Players')
local SlockMessage = script.Parent.GUI.SlockMessage

local SlockEnabled
local Prefix = Config.Prefix

SlockEnabled = Config.StartLocked

Players.PlayerAdded:Connect(function(Player)

	SlockMessage:Clone().Parent = Player.PlayerGui
	local Rank = Player:GetRankInGroup(Config.GroupID)

	if SlockEnabled and Rank < Config.MinRank then
		Player:Kick(Config.KickMessage)
	end

	Player.Chatted:Connect(function(Message)
		Message = string.lower(Message)

		if Rank >= Config.AdminRank then
			if Message == Prefix..'slock on' and SlockEnabled then
				SlockEnabled = true
				if Config.SlockMessage then
					Slock:FireAllClients(true,Config.SlockLockMessageContent)
				end
			elseif Message == Prefix..'slock off' and not SlockEnabled then
				SlockEnabled = false
				if Config.SlockMessage then
					Slock:FireAllClients(false,Config.SlockUnlockMessageContent)
				end
			end
		end
	end)
end)




When I run :slock on, it doesn’t work!
I don’t get any errors! Why does this happen?

Have you tried print debugging to see where the script stops?

It looks like you should flip-flop the SlockEnabled variable, either in the condition or the body.

-- Psuedocode
if --[[:slock on]] and not SlockEnabled then
    SlockEnabled = true
    -- turn on slock
elseif --[[:slock off]] and SlockEnabled then
    SlockEnabled = false
    -- turn off slock
end

What’s happening right now is you can only turn off the slock when it is off and vice versa, so you can never switch states properly and instead stay stagnant.