【问题标题】:Can someone tell me why my script is wrong谁能告诉我为什么我的脚本是错误的
【发布时间】:2020-02-16 01:17:35
【问题描述】:

所以我的 Anti godmode 漏洞利用脚本不正确。我需要修复它,以便人们可以进入上帝模式。

game.Players.PlayerAdded:Connect(function(plr)

end)

game.Players.PlayerAdded:Connect(function(plr)
    if plr and plr:FindFirstChild("Humanoid") then

    end
end)

找到玩家的类人机器人并将其本地化:)

'end' 是 if 语句的结束。

    end
end
game.Players.PlayerAdded:Connect(function(plr)
    if plr and plr:FindFirstChild("Humanoid") then
        if plr:FindFirstChild("Humanoid").Health == 100 then
            print(plr.Character.Name.." is a good player he didn't exploits :)")
        else
            plr:Kick("You have been banned by hacking into god mode >:(")
        end
    end
end)

【问题讨论】:

  • 请重新格式化您的代码并解释发生了什么问题。您预计会发生什么以及究竟发生了什么?你有错误吗?
  • 检查以确保Humanoid 的健康状况正好是 100 是个坏主意。如果非剥削者低于完全健康状况会发生什么?根据您编写的 if-then 条件,该玩家仍会被踢。此外,Humanoid 是玩家角色模型的成员,而不是 Player 对象。
  • 所有你需要做的就是在plr:Kick()之前添加额外的检查,这样人们就可以接受没有100的健康。所以你应该问问自己,你想让人们如何获得上帝模式?他们需要加入特定的组吗?他们需要购买游戏通行证吗?他们需要输入秘密密码吗?当您知道后,您应该根据 khoekman 的建议更新您的问题。

标签: lua roblox


【解决方案1】:

这很简单,PlayerAdded 获取玩家实例,并且您试图找到一个永远不会存在于 Player 下的 Humanoid 实例,作为角色对象的后代。

你的代码应该是……

game.Players.PlayerAdded:Connect(function(plr) -- Grab the player instance on join
    plr.CharacterAdded:Connect(function(character) -- Grab the character once it loads
        character:WaitForChild("Humanoid") -- Wait for the humanoid object
        if character:FindFirstChild("Humanoid").Health <= 100 then
            print(plr.Name.." is a good player he didn't exploits :)")
        else
            plr:Kick("You have been banned by hacking into god mode >:(")
        end
    end)
end)

现在,这就是您修复代码的方法,但实际上,这不是使用 Godmode 检测利用者的好方法,因为这种方法只会检查一次。我建议做一些循环,比如......

while wait(1) do
    if character.Humanoid.Health > 100 then
        plr:Kick("Invalid health")
    end
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 2013-05-29
    相关资源
    最近更新 更多