Advertisement
pkgupdate

fly

Feb 10th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. local c = workspace.CurrentCamera
  2. local player = game.Players.LocalPlayer
  3. local userInput = game:GetService("UserInputService")
  4. local rs = game:GetService("RunService")
  5. local starterPlayer = game:GetService("StarterPlayer")
  6.  
  7. local selected = false
  8. local speed = 60
  9. local lastUpdate = 0
  10.  
  11. function getNextMovement(deltaTime)
  12. local nextMove = Vector3.new()
  13. -- Left/Right
  14. if userInput:IsKeyDown("A") or userInput:IsKeyDown("Left") then
  15. nextMove = Vector3.new(-1,0,0)
  16. elseif userInput:IsKeyDown("D") or userInput:IsKeyDown("Right") then
  17. nextMove = Vector3.new(1,0,0)
  18. end
  19. -- Forward/Back
  20. if userInput:IsKeyDown("W") or userInput:IsKeyDown("Up") then
  21. nextMove = nextMove + Vector3.new(0,0,-1)
  22. elseif userInput:IsKeyDown("S") or userInput:IsKeyDown("Down") then
  23. nextMove = nextMove + Vector3.new(0,0,1)
  24. end
  25. -- Up/Down
  26. if userInput:IsKeyDown("Space") then
  27. nextMove = nextMove + Vector3.new(0,1,0)
  28. elseif userInput:IsKeyDown("LeftControl") then
  29. nextMove = nextMove + Vector3.new(0,-1,0)
  30. end
  31. return CFrame.new( nextMove * (speed * deltaTime) )
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement