Hello there, I am trying to add a script to stop exploiters from increasing their speed from the default speed (16). I am not a script and I don’t know much about scripting so I do not know why this script isn’t working.
It’s a server script placed into StarterCharacterScripts
Script:
while true do
wait(1)
if script.Parent.Humanoid.WalkSpeed >= 22 then
Player = game.Players:GetPlayerFromCharacter(script.Parent)
Player:Kick("Speed exploits detected.. You have been kicked for use of exploits.")
end
end
It wouldn’t work because client changes wouldn’t be replicated to the server, the server wouldn’t see the value being changed from the client. You gotta do it on the client side, also just listen for property change so you don’t have to run a loop.
You should try a simple thing but hide it well, some exploiters could delete it.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Char)
while wait() do
if Char.Humanoid.WalkSpeed >= 22 then
plr:Kick("Speed Exploits Detected.. You were kicked you big meanie hacker")
end
end
end)
end)
but thats besides the point it is actually bad practice because the value of wait() isnt a true value its a “truey” value and it takes longer for the computer to decide wait is true than true is true
game.Players.PlayerAdded:Connect(function(plr)
local hum = workspace:WaitForChild(plr.Name).Humanoid
hum.Changed:Connect(function()
if hum.WalkSpeed > 16 then
plr:Kick()
end
end)
end)
spawn(function()
task.wait(.5)
local Backup = script:clone()
local Character = script.Parent
local RunService = game:GetService("RunService")
local Player = game.Players:GetPlayerFromCharacter(Character)
local ActualCharacter = Player.Character or Player.CharacterAdded:Wait()
local ActualHumanoid = ActualCharacter:WaitForChild("Humanoid")
ActualHumanoid.Changed:Connect(function(Property)
if Property == "WalkSpeed" then
game.ReplicatedStorage:WaitForChild("Actions"):FireServer("Speed", ActualHumanoid.WalkSpeed)
end
end)
RunService.RenderStepped:Connect(function()
if script == nil then
Backup.Parent = ActualCharacter
end
if script.Disabled then
script.Disabled = false
end
end)
-- // Write your whole code here...
end)
Put Remote Event into ReplicatedStorage and name it: Actions
Put Script [Server script ofc] Into ServerScriptService
Script’s Source >
spawn(function()
task.wait(.5)
game.ReplicatedStorage.Actions.OnServerEvent:Connect(function(Player, Action, Value)
if Action == "Speed" then
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
if Value >= 22 then
Player:Kick("Speed exploits detected.. You have been kicked for use of exploits.")
end
end
end)
-- // Write your whole code here...
end)