Как добавить скрипт на полёт в роблокс студио! СКРИПТЫ!

Опубликовано: 15 Октябрь 2024
на канале: MIMPI KIK
6,009
102

Скрипт:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local cam = workspace.CurrentCamera
local uis = game:GetService("UserInputService")

local wPressed = false
local sPressed = false
local aPressed = false
local dPressed = false

local flying = false
uis.InputBegan:Connect(function(key, chat)
if chat then return end
if key.KeyCode == Enum.KeyCode.F then
if flying then
flying = false
else
flying = true
local bv = Instance.new("BodyVelocity", char.PrimaryPart)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = Vector3.new(0,0,0)
bv.Name = "FlightForce"

repeat wait(0.1) until flying == false
bv:Destroy()
end
end

if key.KeyCode == Enum.KeyCode.W then
wPressed = true
elseif key.KeyCode == Enum.KeyCode.S then
sPressed = true
elseif key.KeyCode == Enum.KeyCode.A then
aPressed = true
elseif key.KeyCode == Enum.KeyCode.D then
dPressed = true
end
end)

uis.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.W then
wPressed = false
elseif key.KeyCode == Enum.KeyCode.S then
sPressed = false
elseif key.KeyCode == Enum.KeyCode.A then
aPressed = false
elseif key.KeyCode == Enum.KeyCode.D then
dPressed = false
end
end)

while wait() do
if flying then
char.PrimaryPart:FindFirstChild("FlightForce").Velocity = Vector3.new(0,0,0)

if wPressed then
char.PrimaryPart:FindFirstChild("FlightForce").Velocity = cam.CFrame.LookVector * 100
end
if sPressed then
char.PrimaryPart:FindFirstChild("FlightForce").Velocity = cam.CFrame.LookVector * -100
end
if aPressed then
char.PrimaryPart:FindFirstChild("FlightForce").Velocity = cam.CFrame.RightVector * -100
end
if dPressed then
char.PrimaryPart:FindFirstChild("FlightForce").Velocity = cam.CFrame.RightVector * 100
end
else
wait(1)
end
end