Script:
_G.Speed = 150
_G.Key = Enum.KeyCode.X
local UIS = game:GetService("UserInputService")
local OnRender = game:GetService("RunService").RenderStepped
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local Root = Character:WaitForChild("HumanoidRootPart")
local C1, C2, C3;
local UntitledHood = {Flying = false, Forward = false, Backward = false, Left = false, Right = false}
C1 = UIS.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Input.KeyCode == _G.Key then
UntitledHood.Flying = not UntitledHood.Flying
Root.Anchored = UntitledHood.Flying
elseif Input.KeyCode == Enum.KeyCode.W then
UntitledHood.Forward = true
elseif Input.KeyCode == Enum.KeyCode.S then
UntitledHood.Backward = true
elseif Input.KeyCode == Enum.KeyCode.A then
UntitledHood.Left = true
elseif Input.KeyCode == Enum.KeyCode.D then
UntitledHood.Right = true
end
end
end)
C2 = UIS.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Input.KeyCode == Enum.KeyCode.W then
UntitledHood.Forward = false
elseif Input.KeyCode == Enum.KeyCode.S then
UntitledHood.Backward = false
elseif Input.KeyCode == Enum.KeyCode.A then
UntitledHood.Left = false
elseif Input.KeyCode == Enum.KeyCode.D then
UntitledHood.Right = false
end
end
end)
C3 = Camera:GetPropertyChangedSignal("CFrame"):Connect(function()
if UntitledHood.Flying then
Root.CFrame = CFrame.new(Root.CFrame.Position, Root.CFrame.Position + Camera.CFrame.LookVector)
end
end)
while true do
local Delta = OnRender:Wait()
if UntitledHood.Flying then
if UntitledHood.Forward then
Root.CFrame = Root.CFrame + (Camera.CFrame.LookVector * (Delta * _G.Speed))
end
if UntitledHood.Backward then
Root.CFrame = Root.CFrame + (-Camera.CFrame.LookVector * (Delta * _G.Speed))
end
if UntitledHood.Left then
Root.CFrame = Root.CFrame + (-Camera.CFrame.RightVector * (Delta * _G.Speed))
end
if UntitledHood.Right then
Root.CFrame = Root.CFrame + (Camera.CFrame.RightVector * (Delta * _G.Speed))
end
end
end
Post a Comment (0)