Hi @ThtRookie
Its not perfect,in some cases there will be flaws when teleporting players to other parts of map or just enable admin command for flying and speed boost this is just an example i cannot guarantee that will let some other scripts work property (speed boost,flying,teleport to other zone)
I made anticheat for flying,teleporting,speed hacks
Network Ownership or BodyPosition is not only problem
Don’t change NetworkOwnership script ,add new because its useless my scripts when NetworkOwnership is set to other player.
this is for speed,fly,teleport hacks this is especially for you problem:
-- Anti Teleport , Anti-Fly , Anti-Speed
-- Place this in ServerScriptService
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local CHECK_INTERVAL = 0.5 -- seconds
local MAX_WALK_SPEED = 20 -- normal walk/run speed
local MAX_TELEPORT_DISTANCE = 30 -- studs per 0.5s (natural player movement)
local MAX_AIR_HEIGHT = 10 -- studs above ground before considered flying
local MAX_AIR_TIME = 2 -- seconds
local playerData = {}
local function getGroundHeight(position)
local rayOrigin = position
local rayDirection = Vector3.new(0, -500, 0)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.IgnoreWater = true
local result = workspace:Raycast(rayOrigin, rayDirection, params)
if result then
return result.Position.Y
else
return nil
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local rootPart = character:WaitForChild("HumanoidRootPart")
playerData[player] = {
LastPosition = rootPart.Position,
LastGroundTime = tick(),
}
end)
end)
Players.PlayerRemoving:Connect(function(player)
playerData[player] = nil
end)
RunService.Heartbeat:Connect(function(deltaTime)
for _, player in ipairs(Players:GetPlayers()) do
local data = playerData[player]
if data and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
local rootPart = player.Character.HumanoidRootPart
local currentPos = rootPart.Position
-- 1. Check speed (horizontal movement)
local velocityXZ = Vector3.new(rootPart.Velocity.X, 0, rootPart.Velocity.Z)
local horizontalSpeed = velocityXZ.Magnitude
if horizontalSpeed > MAX_WALK_SPEED + 5 then
rootPart.CFrame = CFrame.new(data.LastPosition)
warn(player.Name .. " moved too fast, teleporting back.")
continue
end
-- 2. Check flying
local groundY = getGroundHeight(currentPos)
if groundY then
local heightAboveGround = currentPos.Y - groundY
if heightAboveGround > MAX_AIR_HEIGHT then
if tick() - data.LastGroundTime > MAX_AIR_TIME then
rootPart.CFrame = CFrame.new(data.LastPosition)
warn(player.Name .. " was flying too long, teleporting back.")
continue
end
else
data.LastGroundTime = tick()
end
end
-- 3. Check sudden teleport
local distanceMoved = (currentPos - data.LastPosition).Magnitude
if distanceMoved > MAX_TELEPORT_DISTANCE then
-- Player moved too far too fast = suspicious teleport
rootPart.CFrame = CFrame.new(data.LastPosition)
warn(player.Name .. " teleported suspiciously, teleporting back.")
continue
end
-- 4. Update safe position
data.LastPosition = currentPos
end
end
end)
Give something like this for your ring crediting system:
Most improtant part is check for Distance : Distance < 5:
local Players = game:GetService("Players")
local Part = Instance.new("Part") -- Change with your part
Part.Touched:Connect(function(hit)
local Char = hit.Parent
local Player = Players:GetPlayerFromCharacter()
if Char and Player then
local HumanoidrRootPart:Part = Char:FindFirstChild("HumanoidRootPart")
local Distance = (Part.Position - HumanoidrRootPart.Position).Magnitude
if Distance < 5 then
-- Credit something
end
end
end)