有人可以告诉我为什么我的脚本错误吗

时间:2019-10-19 06:21:06

标签: lua roblox

所以我的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)

1 个答案:

答案 0 :(得分:0)

这很简单,PlayerAdded获取播放器实例,并且您试图找到一个在播放器下永远不存在的类人动物实例,作为其角色对象的后代。

您的代码应为...

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