I'm using a script that when you say the keyword (ring/), you have to type in the persons whole name and they'll be teleported to the ring if the person saying it is an admin. I'm trying to figure out an edit I can make so that I don't have to type in the persons full name, but I can't figure it out. I did not write this, but I am using it, seeing as it's a utility a lot of other people use.
print("teleport")
jail = script.Parent
permission = { "CrazedAce" } --Place Admins Here
function check(name)
if table.maxn(permission) == 0 then return true end --If table contains no values, returns true
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)
-- convert to all lower case
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if not check(source) then return end
if string.match(msg, "bs") then --change Tele to what ever u want to say before the name
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)
I believe I have to edit something after the comment about string conversion, but I'm not sure. Please help.
