So, I am trying to do an anti cheat system and I've tried this script but the problem is that its calling a function in an if statement
local player = game.Players.LocalPlayer
local speed = 10
local mouse = player:GetMouse()
local isFlying = false
function GetMassRecursive(p)
local mass = 0
for i,v in pairs(p:GetChildren())do
if #v:GetChildren() > 0 then
mass = mass + GetMassRecursive(v)
end
if v:IsA("Part") then
print(v.Name)
mass = mass + v:GetMass()
end
end
return mass
end
function Flying(p)
speed = 10
local f = Instance.new("BodyForce")
f.Name = "Anti-Grav"
f.Force = Vector3.new(0,196.2,0) * (GetMassRecursive(player.Character))
f.Parent = player.Character.Torso
local v = Instance.new("BodyVelocity")
v.Velocity = (mouse.Hit.p - player.Character.Torso.Position).unit * 10
v.P = 100
v.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
v.Name = "FlyingVelocity"
v.Parent = player.Character.Torso
player.Character.Humanoid.PlatformStand = true
isFlying = true
end
function NotFlying(p)
speed = 0
wait()
player.Character.Torso["Anti-Grav"]:Destroy()
player.Character.Torso["FlyingVelocity"]:Destroy()
player.Character.Humanoid.PlatformStand = false
isFlying = false
end
function KickFly()
player:Kick("Fly hacking...")
end
while wait(1)do
if Flying() then
NotFlying()
isFlying = true
end
end
if isFlying == true then
KickFly()
end
sorry if the script is too long, but the problem is at line 53

4 comments
wait() should NOT be the loop's condition.
Ok, sorry. It's just for testing purposes.
then don't call the function at line 53 lol
But, I want to check if the player is doing the function, how would I do that?