我如何设置一些名称以便能够在roblox中键入命令来杀死其他人

时间:2018-12-26 16:57:22

标签: roblox

我正在制作一个即将到来的大亨,我想要管理员的权限,这让我想起了奥斯丁的权限。无论如何,我需要让我输入: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)

1 个答案:

答案 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

这现在应该可以杀死其他玩家!