Что не так с этим скриптом в roblox studio и почему он работает, но как то стронно?
local player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local FLY_KEY = Enum.KeyCode.F
local FLY_SPEED = 30
local MOUSE_SENSITIVITY = 0.15 -- Нормальная чувствительность
local ANTI_GRAVITY_FORCE = 2 -- Сила противодействия гравитации
local flying = false
local character, humanoid, rootPart
local camera = workspace.CurrentCamera
local flightConnection
local cameraAngleX = 0
local cameraAngleY = 0
local function setupCharacter()
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
rootPart = character:WaitForChild("HumanoidRootPart")
end
local function startFlight()
if flightConnection then flightConnection:Disconnect() end
cameraAngleX = math.asin(camera.CFrame.LookVector.Y)
cameraAngleY = math.atan2(-camera.CFrame.LookVector.X, -camera.CFrame.LookVector.Z)
flightConnection = RunService.Heartbeat:Connect(function(dt)
if not flying or not rootPart or not rootPart.Parent then return
if UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then
local mouseDelta = UIS:GetMouseDelta()
cameraAngleX = cameraAngleX - mouseDelta.Y * MOUSE_SENSITIVITY
cameraAngleY = cameraAngleY - mouseDelta.X * MOUSE_SENSITIVITY
cameraAngleX = math.clamp(cameraAngleX, -80, 80)
end
local moveVec = Vector3.new()
local camCF = CFrame.Angles(0, cameraAngleY, 0) * CFrame.Angles(cameraAngleX, 0, 0)
if UIS:IsKeyDown(Enum.KeyCode.W) then moveVec += camCF.LookVector end
if UIS:IsKeyDown(Enum.KeyCode.S) then moveVec -= camCF.LookVector end
if UIS:IsKeyDown(Enum.KeyCode.A) then moveVec -= camCF.RightVector end
if UIS:IsKeyDown(Enum.KeyCode.D) then moveVec += camCF.RightVector end
if UIS:IsKeyDown(Enum.KeyCode.Space) then moveVec += Vector3.new(0,1,0) end
if UIS:IsKeyDown(Enum.KeyCode.LeftControl) then moveVec += Vector3.new(0,-1,0) end
moveVec += Vector3.new(0, ANTI_GRAVITY_FORCE, 0)
if moveVec.Magnitude > 0 then
moveVec = moveVec.Unit * FLY_SPEED
end
rootPart.Velocity = moveVec
camera.CFrame = CFrame.new(rootPart.Position) *
CFrame.Angles(0, cameraAngleY, 0) *
CFrame.Angles(cameraAngleX, 0, 0) *
CFrame.new(0, 0, 5)
end)
end
local function stopFlight()
if flightConnection then
flightConnection:Disconnect()
flightConnection = nil
end
if rootPart then
rootPart.Velocity = Vector3.new()
end
end
UIS.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == FLY_KEY and not gameProcessed then
flying = not flying
if flying then
startFlight()
else
stopFlight()
end
end
end)
setupCharacter()
player.CharacterAdded:Connect(function(newChar)
setupCharacter()
if flying then
task.wait(0.5)
startFlight()
end
end)
Можете его сами проверить в Roblox Studio скопировав его и вставить в LocalPlayerScripts --> LocalScripts и по возможности исправить мои ошибки
потому-что надо самому писать, а не неиронку копировать