ROBLOX杀死指定玩家的命令。

我想制作一个命令,可以杀死指定的玩家。

比如说我输入:kill/Paul。现在我想杀死名字叫做Paul的玩家。

这是我的命令脚本:

local player = ...

game.Players.PlayerAdded:connect(function(player) --这里获取连接的玩家
    player.Chatted:connect(function(message) --这个函数会在玩家在聊天框中输入文字时执行
    --命令写在这里
    if player.Name == "TominoCZ" 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)

现在你可以看到,我已经有一个命令可以杀死执行它的玩家。

但是我怎么能通过在“kill/”之后指定玩家的名字来杀死不同的玩家呢?

这个命令脚本可能看起来太长或者不太专业,但至少我知道并理解它的功能。

有什么想法吗?

点赞
用户2595596
用户2595596

你可以像这样做:

local player = ...

game.Players.PlayerAdded:connect(function(player) --得到连接的玩家
    player.Chatted:connect(function(message) --当玩家在聊天时执行的函数
    --放置命令的位置
    if string.sub(message,1,string.len("kill/"))=="kill/" then --检查消息是否以命令“kill/”开头
        if string.sub(message,string.len("kill/"))==player.Name then --杀掉指定名字的玩家
            player.Character.Head:remove()
            end
    end)
end)

我不了解Lua,因此可能会出现语法错误,但总体思路是使用 string.sub 方法将消息分成两部分:命令和信息部分。如果命令部分等于 "kill/",则查找指定信息部分的玩家,并将其杀死!(或者斩首…我不玩ROBLOX :D)

2015-08-01 03:10:46