Right now ive scripted a anti-noclip and anti-speed script but im sure that theres a way you can bypass it. I want someone to try to bypass this system. Also if theres a way my script can be better please tell me.
script:
local times = 0
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
wait(1)
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
while true do
local oldpos = HumanoidRootPart.CFrame.Position
wait(0.1)
local ignor = {}
for i,v in pairs(char:GetDescendants()) do
table.insert(ignor, v)
end
local ray = Ray.new(oldpos, (HumanoidRootPart.Position - oldpos).Unit *(HumanoidRootPart.Position - oldpos).Magnitude)
local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, ignor)
if hit then
if times <= 10 then
HumanoidRootPart.Position = oldpos
times = times + 1
else
player:Kick("SERVER for passing through " .. hit.Name)
char:Destroy()
times = 0
end
end
if char.BypassSpeed.Value == false and (HumanoidRootPart.Position - oldpos).Magnitude > 6 then
HumanoidRootPart.Position = oldpos
end
end
end)
end)
I tried it out.
Because it sets HumanoidRootPart.Position instead of CFrame, the HumanoidRootPart gets disconnected from the Torso server-side, which makes for a funny sight on the server view, where the visible player model moves at mach 1 whenever the actual player (HumanoidRootPart) turns.
Reading the script-
theoretically, you could teleport yourself whereever you like during that 1 second before the script even begins looking for the HumanoidRootPart. Or destroy the HumanoidRootPart somehow, which creates a small memory leak and ensures that the script won’t affect that character again until it dies and is respawned.
I also had it tell me it kicked me for passing through HumanoidRootPart on a test, though I don’t know how that would be.
It also doesn’t forgive, so the kick for noclipping will be inevitable if you play long enough.
For that matter, the times variable is global to all players, so if an exploiter trips it 9 times and someone else has a false positive, the innocent player is the one who gets kicked.
The anti-speed will likely make falling players stutter.
I didn’t test if BypassSpeed can be destroyed by the client and have it replicate to the server.
#1. You don’t manage already loaded players and characters
There is a chance where players and characters have already loaded before your code runs, so PlayerAdded or CharacterAdded won’t fire.
Something like this:
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local function onCharacterAdded(character)
if not character:IsDescendantOf(workspace) then
character.AncestryChanged:Wait()
end
-- your raycast stuff...
end
if not player.Character then
coroutine.wrap(onCharacterAdded)(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
for _, player in ipairs(Players:GetPlayers()) do
coroutine.wrap(onPlayerAdded)(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
#2. Every time your character respawns, the while loops will stack, and the previous one won’t stop.
CharacterAdded is fired whenever your character respawns, so if your character dies, the while loop doesn’t stop and another while loop is added. This can significantly lag your game.
So instead of while true do, just check if the character is alive in the condition statement:
Get the character’s Humanoid so you can check its health while humanoid.Health > 0 do
#3. Use the new raycasting API
Roblox just released a new Raycasting API, that you should use. FindPartOnRay methods are deprecated and should not be used in new work.