How to make a Fly Script without using BodyMovers?

I really really want to make a Fly Script for my ADMIN without using BodyMovers (To Stop Hacking). But the problem with that is it stops me making a fly script. So I would like it if someone could help me make a Non-BodyMovers Fly Script, please.

This is the only way I know how to make a fly script

local camera = game.Workspace.CurrentCamera;

local character = game.Players.LocalPlayer.CharacterAdded:Wait();
local hrp = character:WaitForChild("HumanoidRootPart");
local humanoid = character:WaitForChild("Humanoid");
local animate = character:WaitForChild("Animate");

while (not character.Parent) do character.AncestryChanged:Wait(); end
local idleAnim = humanoid:LoadAnimation(script:WaitForChild("IdleAnim"));
local moveAnim = humanoid:LoadAnimation(script:WaitForChild("MoveAnim"));
local lastAnim = idleAnim;

local bodyGyro = Instance.new("BodyGyro");
bodyGyro.maxTorque = Vector3.new(1, 1, 1)*10^6;
bodyGyro.P = 10^6;

local bodyVel = Instance.new("BodyVelocity");
bodyVel.maxForce = Vector3.new(1, 1, 1)*10^6;
bodyVel.P = 10^4;

local isFlying = false;
local isJumping = false;
local movement = {forward = 0, backward = 0, right = 0, left = 0};

-- functions

local function setFlying(flying)
	isFlying = flying;
	bodyGyro.Parent = isFlying and hrp or nil;
	bodyVel.Parent = isFlying and hrp or nil;
	bodyGyro.CFrame = hrp.CFrame;
	bodyVel.Velocity = Vector3.new();
	
	animate.Disabled = isFlying;
	
	if (isFlying) then
		lastAnim = idleAnim;
		lastAnim:Play();
	else
		lastAnim:Stop();
	end
end

local function onUpdate(dt)
	if (isFlying) then
		local cf = camera.CFrame;
		local direction = cf.rightVector*(movement.right - movement.left) + cf.lookVector*(movement.forward - movement.backward);
		
		if (direction:Dot(direction) > 0) then
			direction = direction.unit;
		end

		bodyGyro.CFrame = cf;
		bodyVel.Velocity = direction * humanoid.WalkSpeed * 3;
	end
end

local function onJumpRequest()
	if (not humanoid or humanoid:GetState() == Enum.HumanoidStateType.Dead) then
		return;
	end
	
	if (isFlying) then
		setFlying(false);
		isJumping = false;
	elseif (isJumping) then
		setFlying(true);
	end
end
	
local function onStateChange(old, new)
	if (new == Enum.HumanoidStateType.Landed) then	
		isJumping = false;
	elseif (new == Enum.HumanoidStateType.Jumping) then
		isJumping = true;
	end
end

local function movementBind(actionName, inputState, inputObject)
	if (inputState == Enum.UserInputState.Begin) then
		movement[actionName] = 1;
	elseif (inputState == Enum.UserInputState.End) then
		movement[actionName] = 0;
	end
	
	if (isFlying) then
		local isMoving = movement.right + movement.left + movement.forward + movement.backward > 0;
		local nextAnim = isMoving and moveAnim or idleAnim;
		if (nextAnim ~= lastAnim) then
			lastAnim:Stop();
			lastAnim = nextAnim;
			lastAnim:Play();
		end
	end
	
	return Enum.ContextActionResult.Pass;
end

-- connections

humanoid.StateChanged:Connect(onStateChange);
game:GetService("UserInputService").JumpRequest:Connect(onJumpRequest);

game:GetService("ContextActionService"):BindAction("forward", movementBind, false, Enum.PlayerActions.CharacterForward);
game:GetService("ContextActionService"):BindAction("backward", movementBind, false, Enum.PlayerActions.CharacterBackward);
game:GetService("ContextActionService"):BindAction("left", movementBind, false, Enum.PlayerActions.CharacterLeft);
game:GetService("ContextActionService"):BindAction("right", movementBind, false, Enum.PlayerActions.CharacterRight);

game:GetService("RunService").RenderStepped:Connect(onUpdate)

IF ANYONE COULD HELP WITH MY PROBLEM IT WOULD BE GREAT I REALLY NEED THIS THANK YOU!

2 Likes

STILL NEED HELP WITH THIS RIGHT NOW lolololololol

I believe you could add a Vector3 value to the position, like:

HumanoidRootPart.CFrame = HumanoidRootPart.CFrame + CFrame.new(Vector3.new(0,50,0))

No idea if that works or not, it’s the only way I can think of other than BodyMovers. Maybe try it, though.

Yeah I looked at that I want it to be smooth not teleporting last time i remember you dont teleport in a FLY script.

Yes. Other than that, you may only be able to tween the position. So you could do that same thing, finding the new position by adding a CFrame, then tweening to that CFrame.