Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Press X to fly
- local plr = game.Players.LocalPlayer
- local mouse = plr:GetMouse()
- local localplayer = plr
- if workspace:FindFirstChild("Core") then
- workspace.Core:Destroy()
- end
- local Core = Instance.new("Part")
- Core.Name = "Core"
- Core.Size = Vector3.new(0.05, 0.05, 0.05)
- spawn(function()
- Core.Parent = workspace
- local Weld = Instance.new("Weld", Core)
- Weld.Part0 = Core
- Weld.Part1 = localplayer.Character.LowerTorso
- Weld.C0 = CFrame.new(0, 0, 0)
- end)
- workspace:WaitForChild("Core")
- local torso = workspace.Core
- local flying = true
- local speed = 10
- local keys = {a = false, d = false, w = false, s = false}
- local function start()
- local pos = Instance.new("BodyPosition", torso)
- local gyro = Instance.new("BodyGyro", torso)
- pos.Name = "EPIXPOS"
- pos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- pos.Position = torso.Position
- gyro.MaxTorque = Vector3.new(9e9, 9e9, 9e9)
- gyro.CFrame = torso.CFrame
- repeat
- wait()
- localplayer.Character.Humanoid.PlatformStand = true
- local new = gyro.CFrame - gyro.CFrame.p + pos.Position
- if not keys.w and not keys.s and not keys.a and not keys.d then
- speed = 5
- end
- if keys.w then
- new = new + workspace.CurrentCamera.CoordinateFrame.LookVector * speed
- speed = speed + 0
- end
- if keys.s then
- new = new - workspace.CurrentCamera.CoordinateFrame.LookVector * speed
- speed = speed + 0
- end
- if keys.d then
- new = new * CFrame.new(speed, 0, 0)
- speed = speed + 0
- end
- if keys.a then
- new = new * CFrame.new(-speed, 0, 0)
- speed = speed + 0
- end
- if speed > 10 then
- speed = 5
- end
- pos.Position = new.p
- if keys.w then
- gyro.CFrame = workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(-math.rad(speed * 0), 0, 0)
- elseif keys.s then
- gyro.CFrame = workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(math.rad(speed * 0), 0, 0)
- else
- gyro.CFrame = workspace.CurrentCamera.CoordinateFrame
- end
- until flying == false
- gyro:Destroy()
- pos:Destroy()
- flying = false
- localplayer.Character.Humanoid.PlatformStand = false
- speed = 10
- end
- local function onKeyPress(key)
- if not torso or not torso.Parent then
- flying = false
- mouse.KeyDown:Disconnect()
- mouse.KeyUp:Disconnect()
- return
- end
- if key == "w" then
- keys.w = true
- elseif key == "s" then
- keys.s = true
- elseif key == "a" then
- keys.a = true
- elseif key == "d" then
- keys.d = true
- end
- end
- local function onKeyRelease(key)
- if key == "w" then
- keys.w = false
- elseif key == "s" then
- keys.s = false
- elseif key == "a" then
- keys.a = false
- elseif key == "d" then
- keys.d = false
- end
- end
- mouse.KeyDown:Connect(onKeyPress)
- mouse.KeyUp:Connect(onKeyRelease)
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement