Advertisement
AlphaZyro

Untitled

Mar 15th, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local UserInputService = game:GetService("UserInputService")
  3. local TweenService = game:GetService("TweenService")
  4. local RunService = game:GetService("RunService")
  5. local StarterGui = game:GetService("StarterGui")
  6. local SoundService = game:GetService("SoundService")
  7.  
  8. local localPlayer = Players.LocalPlayer
  9. local character = localPlayer.Character
  10. local mouse = localPlayer:GetMouse()
  11. local camera = workspace.CurrentCamera
  12. local camtype = camera.CameraType
  13.  
  14. local connections = {}
  15.  
  16. lib = {}
  17. lib.wrap = function(f)
  18. return coroutine.wrap(f)()
  19. end
  20. wrap = lib.wrap
  21.  
  22. lib.messageOut = function(title, msg)
  23. StarterGui:SetCore("SendNotification",
  24. {
  25. Title = title,
  26. Text = msg
  27. }
  28. )
  29. end
  30.  
  31. local wait = function(int)
  32. if not int then int = 0 end
  33. local t = tick()
  34. repeat
  35. RunService.Heartbeat:Wait(0)
  36. until (tick() - t) >= int
  37. return (tick() - t), t
  38. end
  39. spawn(function()
  40. lib.messageOut("Admin successfully loaded", "Have fun!")
  41. end)
  42.  
  43. lib.lock = function(instance, par)
  44. locks[instance] = true
  45. instance.Parent = par or instance.Parent
  46. instance.Name = "RightGrip"
  47. end
  48. lock = lib.lock
  49. locks = {}
  50.  
  51. lib.connect = function(name, connection) -- no :(
  52. connections[name .. tostring(math.random(1000000, 9999999))] = connection
  53. return connection
  54. end
  55.  
  56. lib.disconnect = function(name)
  57. for title, connection in pairs(connections) do
  58. if title:find(name) == 1 then
  59. connection:Disconnect()
  60. end
  61. end
  62. end
  63.  
  64. if not speed then speed = 5 end
  65. if connections["fly"] then lib.disconnect("fly") character:FindFirstChildWhichIsA("Humanoid").PlatformStand = false end
  66. local dir = {w = false, a = false, s = false, d = false}
  67. local cf = Instance.new("CFrameValue")
  68.  
  69. flyPart = flyPart or Instance.new("Part")
  70. flyPart.Anchored = true
  71. pcall(function()
  72. flyPart.CFrame = character.HumanoidRootPart.CFrame
  73. end)
  74.  
  75. lib.connect("fly", RunService.RenderStepped:Connect(function()
  76. if not character:FindFirstChild("HumanoidRootPart") then return end
  77. local primaryPart = character.HumanoidRootPart
  78. local humanoid = character:FindFirstChildWhichIsA("Humanoid")
  79.  
  80. local x, y, z = 0, 0, 0
  81. if dir.w then z = -1 * speed end
  82. if dir.a then x = -1 * speed end
  83. if dir.s then z = 1 * speed end
  84. if dir.d then x = 1 * speed end
  85. if dir.q then y = 1 * speed end
  86. if dir.e then y = -1 * speed end
  87.  
  88. for i, v in pairs(character:GetDescendants()) do
  89. if v:IsA("BasePart") then
  90. v.Velocity = Vector3.new(0, 0, 0)
  91. v.RotVelocity = Vector3.new(0, 0, 0)
  92. end
  93. end
  94. flyPart.CFrame = CFrame.new(
  95. flyPart.CFrame.p,
  96. (camera.CFrame * CFrame.new(0, 0, -100)).p
  97. )
  98.  
  99. local moveDir = CFrame.new(x,y,z)
  100. cf.Value = cf.Value:lerp(moveDir, 0.2)
  101. flyPart.CFrame = flyPart.CFrame:lerp(flyPart.CFrame * cf.Value, 0.2)
  102. primaryPart.CFrame = flyPart.CFrame
  103. humanoid.PlatformStand = true
  104. end))
  105. lib.connect("fly", UserInputService.InputBegan:Connect(function(input, event)
  106. if event then return end
  107. local code, codes = input.KeyCode, Enum.KeyCode
  108. if code == codes.W then
  109. dir.w = true
  110. elseif code == codes.A then
  111. dir.a = true
  112. elseif code == codes.S then
  113. dir.s = true
  114. elseif code == codes.D then
  115. dir.d = true
  116. elseif code == codes.Q then
  117. dir.q = true
  118. elseif code == codes.E then
  119. dir.e = true
  120. elseif code == codes.Space then
  121. dir.q = true
  122. end
  123. end))
  124. lib.connect("fly", UserInputService.InputEnded:Connect(function(input, event)
  125. if event then return end
  126. local code, codes = input.KeyCode, Enum.KeyCode
  127. if code == codes.W then
  128. dir.w = false
  129. elseif code == codes.A then
  130. dir.a = false
  131. elseif code == codes.S then
  132. dir.s = false
  133. elseif code == codes.D then
  134. dir.d = false
  135. elseif code == codes.Q then
  136. dir.q = false
  137. elseif code == codes.E then
  138. dir.e = false
  139. elseif code == codes.Space then
  140. dir.q = false
  141. end
  142. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement