Hello i am working on an 'antiSpeed' type exploit thing and i want to know what is the best way to run this script for all the players at the same time ( and of course improvements):
for index, player in pairs(game.Players:GetChildren()) do -- not working i.e not looping in Studio dont know why local StartLocation = player.Character.HumanoidRootPart.Position wait(1) local EndLocation = player.Character.HumanoidRootPart.Position local finalLocation = EndLocation - StartLocation local x = finalLocation.x local z = finalLocation.z print(finalLocation) if x < 0 then x = finalLocation.x - (finalLocation.x*2) -- to give a positive number end if z < 0 then z = finalLocation.z - (finalLocation.z*2) end if x > 17 then player:Kick("Do not cheat") end if z > 17 then player:Kick("Do not cheat") end if x < 17 then -- break the loop and goto to the next player end if x < 17 then -- break the loop and goto to the next player end end --forced player as in 'player = jack001214' i.e working when forced
Thanks,
Why do you have to go through all that trouble?
Can't you just do something as simple as
while wait(1) do if Workspace:GetRealPhysicsFPS() > 65 then game.Players.LocalPlayer:Kick() end end
or
MAX_WALKSPEED = 30 while wait(1) do for i, v in pairs(game:GetService('Players'):GetPlayers()) do wait() pcall(function(egg) if v.Character:WaitForChild('Humanoid').WalkSpeed > 30 then v:Kick('Stop exploiting, ya fatty!') end end) end end
By the way, the answer is
for index, player in pairs(game:GetService('Players'):GetPlayers()) do end--.
This is the fastest way to loop through something because you're not using pairs or ipairs or next, which are all functions which return two values.
local plrs = game:GetService("Players"):GetPlayers() for i = 1, #plrs do local p = plrs[i] -- Player Value -- Do whatever end