I have an Anti-speed exploit script. However I am looking to make it more secure, How can I do that?
The Code
local LPlr = game.Players.LocalPlayer
local Character = LPlr.Character
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
Humanoid.Changed:Connect(function(property) -- Detects if something in the Humanoid has been changed.
if property == "WalkSpeed" then -- Checks if the WalkSpeed was changed
Humanoid.WalkSpeed = 16 -- Resets it to selected number
end
end)
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
Char:WaitForChild("Anti-SpeedHack"):Destroy()
Char:WaitForChild("Humanoid").WalkSpeed = 100
local last_positions = {}
local max_distance = 10 -- studs
game:GetService('RunService').Heartbeat:Connect(function()
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character then
local pos = v.Character.HumanoidRootPart.Position
local last_pos = last_positions[player] -- gets where the player was last
if last_pos then
local distance = last_pos.Magnitude - pos.Magnitude -- distance from then and now
if distance > max_distance then -- if is over the max distance kick
v:Kick('speed thingy')
end
end
last_positions[v] = v.Character.HumanoidRootPart.Position
else
last_positions[v] = nil
end
end)
Of course this is useless if you have stages where you fall for a large distance
A small tip, next time use community resources as its intended use. Even a basic scripter could easily make that up, thats why most posts in this topic take up a few pages full. They are complex but are explained very well.
And for people like builders and artists or anyone that doesn’t know how to script they have no idea what this does.
I’m not trying to sound harsh here but posts like this just clutter the dev forum.