反漏洞服务器端问题(字符为零)
Anti-Exploit Server Sided Problem (Character is nil)
所以我一直在尝试创建一个反漏洞利用系统,但不能通过漏洞利用来禁用它。当我尝试通过使用 (function param1).Character.Humanoid 查看 Humanoid 的任何属性是否发生变化时,我在开发者控制台(在游戏中,而不是在命令行下方)中收到一个错误,显示 attempt to index nil with humanoid
代码
game.Players.PlayerAdded:Connect(function(p)
while true do
if p.Character.Humanoid.Health > 100 or p.Character.Humanoid.MaxHealth > 100 then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Changing Health]")
end
if p.Character.Humanoid.WalkSpeed > 16 then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Increasing Speed]")
end
if p.Character.Humanoid.JumpPower > 50 then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Increasing Jump-Power]")
end
if p.Team ~= game:GetService("Teams")["Miners"] then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Putting Self on a Team]")
end
wait(1);
end
end)
为什么您认为 p.Character
不是 nil
?
Character
... Initially, this property is nil then set when the player’s
character first spawns. Use the Player.CharacterAdded event to detect
when a player’s character properly loads
添加玩家时还没有角色。另外 运行 在永不中断的无限循环中,即使在玩家被踢出之后对我来说也没有太大意义。
当玩家加入游戏时调用PlayerAdded。当他们加入游戏时,角色还没有加载,所以它被设置为 nil。为了 运行 您的代码,在加载角色后使用
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
-- TODO
end)
end)
所以我一直在尝试创建一个反漏洞利用系统,但不能通过漏洞利用来禁用它。当我尝试通过使用 (function param1).Character.Humanoid 查看 Humanoid 的任何属性是否发生变化时,我在开发者控制台(在游戏中,而不是在命令行下方)中收到一个错误,显示 attempt to index nil with humanoid
代码
game.Players.PlayerAdded:Connect(function(p)
while true do
if p.Character.Humanoid.Health > 100 or p.Character.Humanoid.MaxHealth > 100 then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Changing Health]")
end
if p.Character.Humanoid.WalkSpeed > 16 then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Increasing Speed]")
end
if p.Character.Humanoid.JumpPower > 50 then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Increasing Jump-Power]")
end
if p.Team ~= game:GetService("Teams")["Miners"] then
p:Kick("Potential Exploiting Detected. [Exploit Protection: Putting Self on a Team]")
end
wait(1);
end
end)
为什么您认为 p.Character
不是 nil
?
Character
... Initially, this property is nil then set when the player’s character first spawns. Use the Player.CharacterAdded event to detect when a player’s character properly loads
添加玩家时还没有角色。另外 运行 在永不中断的无限循环中,即使在玩家被踢出之后对我来说也没有太大意义。
当玩家加入游戏时调用PlayerAdded。当他们加入游戏时,角色还没有加载,所以它被设置为 nil。为了 运行 您的代码,在加载角色后使用
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
-- TODO
end)
end)