-
What do you want to achieve? Keep it simple and clear!
Topic name is kinda complicated, so here is vid -
What is the issue? Include screenshots / videos if possible!
- What solutions have you tried so far? Did you look for solutions on the Developer Hub? I defenitely have no point why this happens
Code:
local flying = false
local speed = 0.5
local rs = game:GetService("RunService")
local Char = script.Parent.Parent
local root = Char:WaitForChild("HumanoidRootPart")
local camera = game.Workspace.CurrentCamera
local Fly = workspace.RemoteEvents.Console.Functions.Fly
local UIS = game:GetService("UserInputService")
function fly()
local bp = Instance.new("BodyPosition")
bp.MaxForce = Vector3.new()
bp.D = 10
bp.P = 10000
bp.Parent = root
local bg = Instance.new("BodyGyro")
bg.MaxTorque = Vector3.new()
bg.D = 10
bp.MaxForce = Vector3.new(400000,400000,400000)
bg.MaxTorque = Vector3.new(400000,400000,400000)
bg.Parent = root
UIS.InputBegan:Connect(function(input, gameProcessed)
while UIS:IsKeyDown(Enum.KeyCode.W) and Char.Configs.CanFly.Value == true do
rs.RenderStepped:Wait()
bp.Position = root.Position +((root.Position - camera.CFrame.p).unit * speed)
bg.CFrame = CFrame.new(camera.CFrame.p, root.Position)
end
end)
end
function endFlying()
root.BodyPosition:Destroy()
root.BodyGyro:Destroy()
end
Fly.OnClientEvent:Connect(function(toggle)
if toggle == "enable" then
fly()
else
endFlying()
end
end)