我正在制作一个即将到来的大亨,我想要管理员的权限,这让我想起了奥斯丁的权限。无论如何,我需要让我输入:kill [name]或类似的东西,以便能够杀死任何人!请帮忙,我只发现了一个回答其他人的答案,但我听不懂,我试图找到正确的语法,但我不知道。
虽然我找到了它,但是它只针对那个人,也许是kill / .player.Name之类的东西?
game.Players.PlayerAdded:connect(function(player) --this gets the player that connected
player.Chatted:connect(function(message) --this function executes when the player type into chat
--commands are here
if player.Name == "AlexanderYar" or player.Name == "nathancain" or player.Name == "block100000" then
if message == "kill/me" then
player.Character.Head:remove()
end
if message == "ff/me" then
if player.Character:findFirstChild("ForceField") then
player.Character.ForceField:Destroy()
end
Instance.new("ForceField").Parent = player.Character
end
if message == "unff/me" then
if player.Character:findFirstChild("ForceField") then
player.Character.ForceField:Destroy()
end
end
end
end)
end)
答案 0 :(得分:0)
原始代码是这样的:
if message == "kill/me" then
player.Character.Head:remove()
end
替换为以下代码:
if string.sub(message,1,5) == "kill/" then
local targetName = string.sub(message,6)
if targetName == "me" or targetName == "Me" then
player.Character.Head:Destroy()
else
for i,v in ipairs(game.Players:GetPlayers()) do
if string.lower(v.Name) == string.lower(targetName) and v.Character and v.Character:FindFirstChild("Head") then
v.Character.Head:Destroy()
end
end
end
end
这现在应该可以杀死其他玩家!