有人能告诉我我的脚本为什么错误吗?

我的反上帝模式剥削脚本是不正确的。 我需要修复它,以便人们可以进入上帝模式。

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.." 是一个好玩家,他没有剥削:)")
        else
            plr:Kick("您由于黑客入侵上帝模式而被禁止>:(")
        end
    end
end)
点赞
用户12261055
用户12261055

这很简单,PlayerAdded 获取了玩家实例,而您正在尝试查找 Humanoid 实例,它永远不会存在于 Player 下,因为它是 character 对象的后代。

你的代码应该是...

game.Players.PlayerAdded:Connect(function(plr) -- 在加入时获取玩家实例
    plr.CharacterAdded:Connect(function(character) -- 当载入角色时获取角色
        character:WaitForChild("Humanoid") -- 等待 humanoid 对象
        if character:FindFirstChild("Humanoid").Health <= 100 then
            print(plr.Name.."是一个好玩家,他没有利用:)")
        else
            plr:Kick("您因为入侵上帝模式而被封禁 >:(")
        end
    end)
end)

现在,这是修复你的代码的方法,但实际上,这不是检测使用上帝模式的黑客的好方法,因为这种方法只会检查一次。我建议进行某种循环,例如...

while wait(1) do
    if character.Humanoid.Health > 100 then
        plr:Kick("无效的健康状况")
    end
end
2019-10-25 05:59:39