I’ve been trying to make a simple fly script that goes off humanoid move direction but it doesn’t seem to work properly.
I’m assuming its cause the direction vector isn’t being rotated properly but I don’t really know how to do that so I’m posting this.
here’s the code:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid:Humanoid = Character.Humanoid
local RootPart:BasePart = Character.HumanoidRootPart
local Camera = workspace.CurrentCamera
local FlySpeed = 16
local FlyPosition = Instance.new("BodyPosition")
FlyPosition.MaxForce = Vector3.new(100,100,100)
FlyPosition.Position = RootPart.Position
FlyPosition.Parent = RootPart
local MoveDirection = Vector3.zero
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function(dt)
MoveDirection = Camera.CFrame:VectorToObjectSpace(Humanoid.MoveDirection)
FlyPosition.Position = RootPart.Position + MoveDirection * FlySpeed
end)
Here is a good comprehensive tutorial made by @5uphi which uses humanoid.MoveDirection to move.
For explanations why your script might not work
Max force might be too low
Humanoid physics will interfere with the force and apply an opposing forces which is why the tutorial sets humaonid to physics mode to disable the humanoid.