Slock Command not working
Hey, fellow scripters!
I tried creating a !lock and !unlock script that would allow certain ranks to avoid it and that only certain ranks can run !lock and !unlock. After trying to test it, it seems not to work. After trying multiple times to fix it I have come to the conclusion I need to refer to the DevForum. So here I am. I included some instructions so you can understand what each thing is there for.
local Players = game:GetService("Players") -- Gets the service for players
local IsServerLocked = false -- Boolean on server start is set to false
local LockCommand, UnlockCommand = "!lock", "!unlock" -- Commands in string
format
Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(10591136) <= 248 then
if IsServerLocked == true then -- Checks if the server is locked
plr:Kick("Training is currently undergoing. Please join when another session occurs.") -- Kicks the player off of the current server
end
Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(10591136) >= 237 then
plr.Chatted:Connect(function(Message) -- Event gets fired everytime the player has chatted
-- Will use the message to see if it matches the command
if string.lower(Message) == LockCommand then -- Checks if the lowercase version of the users message matches the lock command
IsServerLocked = true -- Sets the boolean to true, locks the server
elseif string.lower(Message) == UnlockCommand then -- Checks if the lowercase version of the message matches the unlock command
IsServerLocked = false -- Sets the boolean to false, Unlocks the server
end
end)
end