Hello developers! I’m Kamikaze. I’m trying to make an anti-exploit script, and I am doing a part where if a player is at a height, too far up, they get banned. I just need help with the determining how high up the player is part. Thanks!
I would cast a ray straight down and measure the distance to the nearest part on that ray.
Get the magnitude between the base plate and player
Get the Magnitude of the (HumanoidRootPart’s Position - “YourStartingPoint” (Which is usually the baseplate)).
Also, banning a Player for being too high is a high chance for a False-Positive to likely occur, as Players could easily just be flung into the air.
More info on Magnitudes here:
I do not know how to do that? Could you teach me?
You can set a max height as a variable, and check the Y Coordinate of the HumanoidRootParts position.
However, simply banning people for being high in the air should be avoided, as Terror said, a player could be flung into the air for a variety of reasons. Rather than simply banning, you could respawn the player.
I would find the Y value of the position of the player’s HumanoidRootPart
Put this is ServerScriptService:
game.Players.PlayerAdded:Connnect(function(plr) --When the player joins do this:
plr.CharacterAdded:Connect(function(char) --Whenever the player respawns do this:
while wait(1) do --Every second do this:
if char:WaitForChild('HumanoidRootPart').Position.Y > 300 then --if the humanoidrootpart doesn't exist, or you just don't want to use it, then you can instead use Torso or LowerTorso; also, change "300" to whatever Y value you want the this code to run when the player is above this Y value
--do whatever you want to do with the exploiter here
end
end
end)
end)
Edit: Thanks to @C0lvy123 for detecting my “ServerStorage” mistake
I assume you mean ServerScriptService, because scripts in ServerStorage don’t run.
It’s very inefficient to use a loop in this case. Instead of having an infinite loop to check a property, use events.
game.Players.PlayerAdded:Connnect(function(plr)
charAdded = plr.CharacterAdded:Connect(function(char)
char:WaitForChild("HumanoidRootPart"):GetPropertyChangedSignal("Position"):Connect(function()
if char.HumanoidRootPart.Position.Y > 300 then
--exploiter ew
end
end
end)
end)