I want to make a script that allows my admins in game to be able to "pull" others. Like, if the person who said the command moves, the person their linked to is dragged with them. I'm brand new to scripting,and I have Khol's Admin Commands. Any ideas?
COMMUNITY QUESTION
How do I make a in game command to link people?
1 answer
If you mean like :kill me or :tp others me then here is the code
local admins = {"yourname"}
local prefix = "!"
function isAdmin(player)
for i,v in pairs(Admins) do
if v == player.Name then
return true
end
end
return false
end
function GrabPlayers(speaker, input)
local collectplayers = {}
if input:match("^!") then
return FindPlayers(speaker, input:sub(2), true)
elseif input == "me" then
table.insert(collectplayers, speaker)
elseif input == "all" then FindPlayers = function(speaker, input)
local collectplayers = {}
if input:match("^!") then
return FindPlayers(speaker, input:sub(2), true)
elseif input == "me" then
table.insert(collectplayers, speaker)
elseif input == "all" then
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
table.insert(collectplayers, v)
end
elseif input == "others" then
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v ~= speaker then
table.insert(collectplayers, v)
end
end
else
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Name:lower():sub(1,#input) == input:lower() then
table.insert(collectplayers, v)
end
end
end
return collectplayers
end
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
table.insert(collectplayers, v)
end
elseif input == "others" then
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v ~= speaker then
table.insert(collectplayers, v)
end
end
else
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v.Name:lower():sub(1,#input) == input:lower() then
table.insert(collectplayers, v)
end
end
end
return collectplayers
end
game:GetService("Players").PlayerAdded:connect(function(player)
if isAdmin(player) then
player.Chatted:connect(function(message)
if message:sub(1,6):lower() == Prefix.."kill " then
local Target = GrabPlayers(player, message:sub(7))
for index,target in next,Target do
if target.Character then
if target.Character:FindFirstChildOfClass("Humanoid") then
target.Character:FindFirstChildOfClass("Humanoid").MaxHealth = -1000
target.Character:FindFirstChildOfClass("Humanoid").Health = -1000
end
end
end
end
end)
end
end)
Then if you say !kill me or !kill others, it will kill you or all other players besides you.
1 comment
0
So, what would I replace to change it from,lets say "kill", to "telaport"?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You should attempt it.