Advertisement
filipaopastebins2134

2D Camera

Feb 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. wait(1)
  2.  
  3. local controlserv = game:GetService("ControllerService")
  4. local inputserv = game:GetService("UserInputService")
  5. local char = game.Players.LocalPlayer.Character
  6. local left,right = false,false
  7. local cam = workspace.CurrentCamera
  8.  
  9. cam.CameraType = 'Scriptable'
  10.  
  11. for i, v in pairs(controlserv:GetChildren()) do
  12. v:Destroy()
  13. end
  14.  
  15. inputserv.InputBegan:connect(function(Input)
  16. if Input.KeyCode == Enum.KeyCode.A then
  17. right = false
  18. left = true
  19. elseif Input.KeyCode == Enum.KeyCode.D then
  20. left = false
  21. right = true
  22. elseif Input.KeyCode == Enum.KeyCode.Space then
  23. char.Humanoid.Jump = true
  24. end
  25. inputserv.InputEnded:connect(function(Input)
  26. if Input.KeyCode == Enum.KeyCode.A then
  27. left = false
  28. elseif Input.KeyCode == Enum.KeyCode.D then
  29. right = false
  30. end
  31. end)
  32. end)
  33.  
  34. coroutine.wrap(function()
  35. while wait() do
  36. local pos = char.Torso.CFrame + Vector3.new(0,7,20)
  37. cam:Interpolate(
  38. pos,
  39. char.Torso.CFrame,
  40. .1
  41. )
  42. end
  43. end)()
  44.  
  45. while wait() do
  46. local pos
  47. if left == true then
  48. pos = char.Torso.Position - Vector3.new(5, 0, 0)
  49. elseif right == true then
  50. pos = char.Torso.Position - Vector3.new(-5, 0, 0)
  51. end
  52. pos = pos or char.Torso.Position
  53. char.Humanoid:MoveTo(pos)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement