Achieve
I want to make my own flying system, such as the Adonis flying command; so I may manipulate it and change it as I see fit. Plus, being able to fly would probably come in handy down the road. This would be triggered by hitting a GUI Button or hitting the E Key Button.
What I understand
- I know how to listen for the key to be pressed, I know how to go off a Text Button
- I know how to trigger things through a button press, whether key or text.
What I don’t understand
- I do not know how to make a player fly.
- I do not know how to make a player stop flying.
- I have no idea where to start when it comes to getting a player to fly.
Script
This is what I got but it’s mainly based off adonis and I’m not sure how I’d toggle this on and off.
CommandModule.Commands["Fly Command"].AllowedToFly[PlayerName] = {
AllowedToFly = false,
Fly = false,
Noclip = false,
Speed = 2,
Function = function(plr,noclip,speed)
if game.Players:FindFirstChild(PlayerName) and game.Players[PlayerName].Character and game.Players[PlayerName].Character:FindFirstChild("HumanoidRootPart") then
local part = game.Players[PlayerName].Character:FindFirstChild("HumanoidRootPart")
if part then
local oldp = part:FindFirstChild("Fly_Position")
local oldg = part:FindFirstChild("Fly_Gyro")
local olds = part:FindFirstChild("Fly_Flight")
if oldp then oldp:Destroy() end
if oldg then oldg:Destroy() end
if olds then olds:Destroy() end
local flightPosition = Instance.new("BodyPosition")
local flightGyro = Instance.new("BodyGyro")
flightPosition.Name = "Flight_Position"
flightPosition.MaxForce = Vector3.new(0, 0, 0)
flightPosition.Position = part.Position
flightPosition.Parent = part
flightGyro.Name = "Flight_Gyro"
flightGyro.MaxTorque = Vector3.new(0, 0, 0)
flightGyro.CFrame = part.CFrame
flightGyro.Parent = part
end
end
end,
}
Any assistance is appreciated.