【问题标题】:ROBLOX Kill command to kill specified playerROBLOX Kill 命令杀死指定玩家
【发布时间】:2022-04-20 13:20:24
【问题描述】:

我想发出一个可以杀死你指定的玩家的命令.. 假设我输入:kill/Paul。现在我想杀掉那个叫保罗的玩家。

这是我的命令脚本:

local player = ...
    
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 == "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/”后面指定玩家的名字来杀死不同的玩家呢?

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

有什么想法吗?

【问题讨论】:

    标签: lua command kill roblox


    【解决方案1】:

    你可以这样做:

    本地玩家 = ... 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 --kill同名玩家 player.Character.Head:remove() 结尾 结尾) 结尾)

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

    【讨论】:

    • ,杀了他! (或者斩首他......我不玩 ROBLOX :D)是的......当你移除玩家身体的任何部分时,他会死 :D
    • 关闭,但要找到我们想要杀死的玩家,我们必须搜索 game.Players。我们对player 的引用将始终引用与该命令聊天的用户。看这个页面,具体是findPlayer函数例子的部分:wiki.roblox.com/index.php?title=Chat_commands
    猜你喜欢
    • 2019-06-17
    • 1970-01-01
    • 2021-04-28
    • 2011-08-17
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多