My friend gave me this adonis flight script and I want to change it around
It immediately sets the player into flight mode and they can fly around until they press F to toggle the flight, but I don’t want it like that. I want the player to be normal until they press F and then they fly and they can keep toggling it on and off, but I don’t know how.
here’s the adonis flight script he gave to me:
local l__UserInputService__1 = game:GetService("UserInputService");
local l__ContextActionService__2 = game:GetService("ContextActionService");
local l__PrimaryPart__3 = script.Parent.PrimaryPart;
if not l__PrimaryPart__3 then
script:Destroy();
end;
local l__LocalPlayer__4 = game:GetService("Players").LocalPlayer;
local v5 = Instance.new("BodyPosition");
v5.Name = "ADONIS_FLIGHT_POSITION";
v5.Parent = l__PrimaryPart__3;
local v6 = Instance.new("BodyGyro");
v6.Name = "ADONIS_FLIGHT_GYRO";
v6.Parent = l__PrimaryPart__3;
local v7 = Instance.new("NumberValue");
v7.Value = 1;
v7.Parent = l__PrimaryPart__3;
local u1 = {};
local function u2(p1, p2)
local v8 = CFrame.new(p1.CFrame.p);
local v9, v10, v11 = (workspace.CurrentCamera.CoordinateFrame - workspace.CurrentCamera.CoordinateFrame.p):toEulerAnglesXYZ();
return v8 * CFrame.Angles(p2 and v11 or v9, v10, v11);
end;
local u3 = {};
local u4 = {};
local function u5(p3, p4)
local v12 = p3:Connect(p4);
table.insert(u1, v12);
return v12;
end;
local u6 = nil;
local u7 = true;
local function u8()
if script.Parent.PrimaryPart ~= l__PrimaryPart__3 then
return;
end;
return true;
end;
local u9 = l__LocalPlayer__4.Character:FindFirstChildOfClass("Humanoid");
local u10 = nil;
local l__Animation__11 = script:WaitForChild("Animation");
local l__RunService__12 = game:GetService("RunService");
local u13 = nil;
u13 = function()
u7 = false;
u9.PlatformStand = false;
if u10 ~= nil then
u10:Stop();
u10 = nil;
end;
if v5 then
v5.maxForce = Vector3.new(0, 0, 0);
end;
if v6 then
v6.maxTorque = Vector3.new(0, 0, 0);
end;
end;
local u14 = false;
local function u15()
local v13 = 0;
local l__Value__14 = v7.Value;
local l__CurrentCamera__15 = workspace.CurrentCamera;
local v16 = {};
local l__CFrame__17 = l__PrimaryPart__3.CFrame;
local u16 = l__Value__14;
local u17 = l__Value__14 / 25;
u5(v7.Changed, function()
u16 = v7.Value;
u17 = u16 / 25;
end);
v5.Position = l__PrimaryPart__3.Position;
v5.MaxForce = Vector3.new(math.huge, math.huge, math.huge);
v6.CFrame = l__PrimaryPart__3.CFrame;
v6.MaxTorque = Vector3.new(9000000000, 9000000000, 9000000000);
u6 = v16;
while u7 and u6 == v16 and u8() do
local v18 = u9:FindFirstChildOfClass("Animator");
if v18 and u10 == nil then
u10 = v18:LoadAnimation(l__Animation__11);
u10:Play();
end;
local v19 = v6.cframe - v6.cframe.p + v5.position;
if not u3.Forward and not u3.Backward and not u3.Up and not u3.Down and not u3.Left and not u3.Right then
v13 = 1;
else
if u3.Up then
v19 = v19 * CFrame.new(0, v13, 0);
v13 = v13 + u17;
end;
if u3.Down then
v19 = v19 * CFrame.new(0, -v13, 0);
v13 = v13 + u17;
end;
if u3.Forward then
v19 = v19 + l__CurrentCamera__15.CoordinateFrame.LookVector * v13;
v13 = v13 + u17;
end;
if u3.Backward then
v19 = v19 - l__CurrentCamera__15.CoordinateFrame.LookVector * v13;
v13 = v13 + u17;
end;
if u3.Left then
v19 = v19 * CFrame.new(-v13, 0, 0);
v13 = v13 + u17;
end;
if u3.Right then
v19 = v19 * CFrame.new(v13, 0, 0);
v13 = v13 + u17;
end;
if u16 < v13 then
v13 = u16;
end;
end;
u9.PlatformStand = true;
v5.position = v19.p;
if u3.Forward then
v6.cframe = l__CurrentCamera__15.CoordinateFrame * CFrame.Angles(-math.rad(v13 * 7.5), 0, 0);
elseif u3.Backward then
v6.cframe = l__CurrentCamera__15.CoordinateFrame * CFrame.Angles(math.rad(v13 * 7.5), 0, 0);
else
v6.cframe = l__CurrentCamera__15.CoordinateFrame;
end;
l__RunService__12.RenderStepped:Wait();
end;
u13();
end;
local function u18()
if not u14 then
u14 = true;
if not u7 then
u7 = true;
coroutine.wrap(u15)();
else
u7 = false;
u13();
end;
wait(0.5);
u14 = false;
end;
end;
u5(l__PrimaryPart__3.DescendantRemoving, function(p5)
if p5 == v5 or p5 == v6 or p5 == v7 then
for v20, v21 in pairs(u1) do
v21:Disconnect();
end;
u13();
end;
end);
local function u19(p6, p7, p8)
if not p7 and p6.UserInputType == Enum.UserInputType.Keyboard then
if p6.KeyCode == Enum.KeyCode.W then
u4.Forward = p8;
u3.Forward = p8;
return;
end;
if p6.KeyCode == Enum.KeyCode.A then
u4.Left = p8;
u3.Left = p8;
return;
end;
if p6.KeyCode == Enum.KeyCode.S then
u4.Backward = p8;
u3.Backward = p8;
return;
end;
if p6.KeyCode == Enum.KeyCode.D then
u4.Right = p8;
u3.Right = p8;
return;
end;
if p6.KeyCode == Enum.KeyCode.Q then
u4.Down = p8;
u3.Down = p8;
return;
end;
if p6.KeyCode == Enum.KeyCode.Space then
u4.Up = p8;
u3.Up = p8;
return;
end;
if p6.KeyCode == Enum.KeyCode.F and p8 == true then
u18();
end;
end;
end;
u5(l__UserInputService__1.InputBegan, function(p9, p10)
u19(p9, p10, true);
end);
u5(l__UserInputService__1.InputEnded, function(p11, p12)
u19(p11, p12, false);
end);
coroutine.wrap(u15)();
if not l__UserInputService__1.KeyboardEnabled then
local function u20(p13, p14)
for v22, v23 in next, {
Forward = (u2(p13, true) * CFrame.new(0, 0, -1) - p13.CFrame.p).p,
Backward = (u2(p13, true) * CFrame.new(0, 0, 1) - p13.CFrame.p).p,
Right = (u2(p13) * CFrame.new(1, 0, 0) - p13.CFrame.p).p,
Left = (u2(p13) * CFrame.new(-1, 0, 0) - p13.CFrame.p).p
} do
if (v23 - p14).Magnitude <= 1.05 and p14 ~= Vector3.new(0, 0, 0) then
u3[v22] = true;
elseif not u4[v22] then
u3[v22] = false;
end;
end;
end;
u5(u9.Changed, function()
u20(l__PrimaryPart__3, u9.MoveDirection);
end);
l__ContextActionService__2:BindAction("Toggle Flight", u18, true);
l__ContextActionService__2:SetPosition("Toggle Flight", UDim2.new(0.5, 0, -0.2, 0));
l__ContextActionService__2:SetImage("Toggle Flight", "rbxassetid://9663439657");
l__LocalPlayer__4.PlayerGui.ContextActionGui.ContextButtonFrame.ContextActionButton.ActionIcon.AnchorPoint = Vector2.new(0.5, 0.5);
l__LocalPlayer__4.PlayerGui.ContextActionGui.ContextButtonFrame.ContextActionButton.ActionIcon.Position = UDim2.new(0.55, 0, 0.45, 0);
l__LocalPlayer__4.PlayerGui.ContextActionGui.ContextButtonFrame.ContextActionButton.ActionIcon.Size = UDim2.new(3.75, 0, 3.75, 0);
while u8() do
l__RunService__12.Stepped:Wait();
end;
l__ContextActionService__2:UnbindAction("Toggle Flight");
end;