I'm trying to edit the script of a model I've been using for a while. I want the script to be able to detect shortened versions of usernames (So, rather than having to type in "bs joemcburger" I could type "bs joe"
This is the code:
print("Jail")
jail = script.Parent
permission = { "joemcburger","burninrubber02","ipwnuFOOLZ"}
function check(name)
if table.maxn(permission) == 0 then return true end
for i = 1,#permission do
if (string.upper(name) == string.upper(permission[i])) then return true end
end
return false
end
function Jail(name)
local player = game.Players:FindFirstChild(name)
local torso = player.Character:FindFirstChild("Torso")
if torso == nil then return end
local location = {jail.Position}
local i = 1
local x = location[i].x
local y = location[i].y
local z = location[i].z
x = x + math.random(-1, 1)
z = z + math.random(-1, 1)
y = y + math.random(2, 3)
local cf = torso.CFrame
local lx = 0
local ly = y
local lz = 0
torso.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz))
end
function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if not check(source) then return end
if string.match(msg, "bs") then -- Between the brackets, this is what you will say when you want the person teleported. So its like, Person1:jail NUBLET then the nub would teleport to the brick this script is in.
local players=game.Players:GetChildren()
for i=1, #players do
if string.match(msg, string.lower(players[i].Name)) then
Jail(players[i].Name)
return
end
end
end
end
function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
game.Players.ChildAdded:connect(onPlayerEntered)

2 comments
Put in code block format please.
Edited for code block. I would recommend tabbing your code properly.