-
What do you want to achieve?
I’m trying to make a flying script using BodyGyros and BodyVelocity, something like this (from Dragon Ball Z Final Stand):
-
What is the issue?
I want the player to face the mouse with BodyGyro but since Anchoring their HumanoidRootPart causes BodyGyro to be ineffective, I don’t know how I would lock the player in mid-air -
What solutions have you tried so far?
Tried using theLocked
, but the player is still dropping to the ground
I also tried usingBodyPosition
, but it isn’t consistent when the player stops flying forward
script.RemoteEvent.OnServerEvent:Connect(function(player,input,mouse,speed)
local character = player.Character
local HumaoidRP = character.HumanoidRootPart
if input == "Start Flying" then
print("Start Flying")
player.isflying.Value = true
character.HumanoidRootPart.Locked = true
end
if input == "Stop Flying" then
print("Stop Flying")
player.isflying.Value = false
character.HumanoidRootPart.Locked = false
if HumaoidRP:FindFirstChildOfClass("BodyVelocity") then
HumaoidRP:FindFirstChildOfClass("BodyVelocity"):Destroy()
end
if HumaoidRP:FindFirstChildOfClass("BodyGyro") then
HumaoidRP:FindFirstChildOfClass("BodyGyro"):Destroy()
end
end
if input == "Forward" then
if HumaoidRP:FindFirstChildOfClass("BodyVelocity") then
HumaoidRP:FindFirstChildOfClass("BodyVelocity"):Destroy()
end
HumaoidRP.Locked = false
local Forward = Instance.new("BodyVelocity",HumaoidRP)
Forward.Name = "ForwardMovement"
Forward.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
Forward.Velocity = mouse.lookVector*speed
wait()
end
if input == "Forward Ended" then
print("Forward Ended")
if HumaoidRP:FindFirstChild("ForwardMovement") then
HumaoidRP.ForwardMovement:Destroy()
HumaoidRP.Locked = true
end
end
if input == "Backward" then
HumaoidRP.Locked = false
if HumaoidRP:FindFirstChildOfClass("BodyVelocity") then
HumaoidRP:FindFirstChildOfClass("BodyVelocity"):Destroy()
end
if HumaoidRP:FindFirstChildOfClass("BodyGyro") then
HumaoidRP:FindFirstChildOfClass("BodyGyro"):Destroy()
end
local Back = Instance.new("BodyVelocity",HumaoidRP)
Back.Name = "BackMovement"
Back.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
Back.Velocity = mouse.lookVector*-40
wait()
end
if input == "Backward Ended" then
print("BackwardEnded")
if HumaoidRP:FindFirstChild("BackMovement") then
HumaoidRP.BackMovement:Destroy()
HumaoidRP.Locked = true
end
end
end)