Hey everyone! I was wondering how I could stop the freeze glitch.
This is my current code, but I’m kind of confused on where to go from here
local Players = game:GetService("Players")
local MaxFreezeTime = 3
function CastRay(StartPos,Vector,Length,IgnoreList)
local Hit,EndPos = workspace:FindPartOnRayWithIgnoreList(Ray.new(StartPos,Vector*Length),IgnoreList)
return Hit,EndPos
end
function OnCharacterAdded(Player,Character)
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local LastVel = Vector3.new()
local CurrentVel = Vector3.new()
local TimeTaken = 0
game:GetService("RunService").Stepped:Connect(function()
if HRP and Humanoid then
if LastVel == CurrentVel and not Humanoid.FloorMaterial then
local Hit,EndPos = CastRay(HRP.Position,(HRP.CFrame.LookVector + Vector3.new(0,-3,0)).Unit,5,{HRP.Parent})
local Distance = (Vector3.new(0,HRP.Position.Y,0) - Vector3.new(0,EndPos.Y,0)).Magnitude
local TimeToFall = math.sqrt((2 * Distance)/workspace.Gravity)
print(TimeToFall)
if not Humanoid.FloorMaterial then
if TimeTaken > TimeToFall then
Player:Kick("Possible freeze glitch detected. If this is a mistake, please rejoin the game.")
end
end
else
LastVel = HRP.Velocity
end
end
end)
end
Players.PlayerAdded:Connect(function(Player)
if Player.Character then
OnCharacterAdded(Player,Player.Character)
end
Player.CharacterAdded:Connect(function(Character)
OnCharacterAdded(Player,Character)
end)
end)
If anyone could help me complete the code, that would be great!
Also, any suggestions are welcome. If I’m going about this the wrong way, please let me know
Sorry about that, I haven’t learned how to use workspace:Raycast() yet, but that isn’t the point of this topic. I’m looking how to prevent the freeze glitch, not for people to tell me not to use this raycasting method. I will be replacing it later, but it should work for now.
game:GetService("RunService").Stepped:Connect(function()
if HRP and Humanoid then
if LastVel == CurrentVel and not Humanoid.FloorMaterial then
local Hit,EndPos = CastRay(HRP.Position,(HRP.CFrame.LookVector + Vector3.new(0,-3,0)).Unit,5,{HRP.Parent})
local Distance = (Vector3.new(0,HRP.Position.Y,0) - Vector3.new(0,EndPos.Y,0)).Magnitude
local TimeToFall = math.sqrt((2 * Distance)/workspace.Gravity)
print(TimeToFall)
if not Humanoid.FloorMaterial then
if TimeTaken > TimeToFall then
Player:Kick("Possible freeze glitch detected. If this is a mistake, please rejoin the game.")
end
end
task.wait()
else
LastVel = HRP.Velocity
task.wait()
end
end
end)
Nah, you can’t. The server doesn’t freeze unlike the client. I don’t think it’s possible to detect if someone’s frames are frozen, since if you’re asking for it, they can give you whatever they want, like an invalid answer.
It uses ping. It detects if ping is too high, and if it is, you will get kicked. And the freeze glitch increases the ping. So, you can add a LocalScript or Script (I dont know how to make ping counter, sorry) that detects if player’s ping is higher that certain amount (somewhere around 800) and kicks the player.
Don’t really think it is the best solution, but I will inform you if I find a better way.
You could use InvokeClient on a RemoteFunction, and count how long it takes for the client to return true or some number back. It’s not advised to use InvokeClient because exploiters get a bit of power. They can make the call hang forever, but you can still detect this as high latency.