CoginzaPizza

MY CREATION

Dec 16th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. local cameraHeight = 12
  2. local cameraZOffset = 20
  3.  
  4. local camera = game.Workspace.CurrentCamera
  5. local player = game.Players.LocalPlayer
  6.  
  7. local function setupCamera()
  8. camera.CFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset), Vector3.new(0,cameraHeight,0))
  9. end
  10. setupCamera()
  11. player.CharacterAdded:connect(setupCamera)
  12. local cameraHeight = 12
  13. local cameraZOffset = 20
  14. local cameraXChase = 10
  15. local cameraSpeed = .25
  16.  
  17. local camera = game.Workspace.CurrentCamera
  18. local player = game.Players.LocalPlayer
  19. local RunService = game:GetService('RunService')
  20.  
  21. local function setupCamera()
  22. camera.CFrame = CFrame.new(Vector3.new(0,cameraHeight,cameraZOffset),
  23. Vector3.new(0,cameraHeight,0))
  24. end
  25. setupCamera()
  26. player.CharacterAdded:connect(setupCamera)
  27.  
  28. local function onUpdate()
  29. if player.Character and player.Character:FindFirstChild('Torso') then
  30. local playerX = player.Character.Torso.Position.X
  31. local cameraX = camera.CFrame.p.X
  32.  
  33. if cameraX - cameraXChase < playerX then
  34. camera.CFrame = camera.CFrame + Vector3.new(cameraSpeed, 0, 0)
  35. end
  36. end
  37. end
  38.  
  39. RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate)
  40. local player = game.Players.LocalPlayer
  41. local RunService = game:GetService('RunService')
  42. local ContextActionService = game:GetService('ContextActionService')
  43.  
  44. local function onLeft(actionName, inputState)
  45.  
  46. end
  47.  
  48. local function onRight(actionName, inputState)
  49.  
  50. end
  51.  
  52. local function onJump(actionName, inputState)
  53.  
  54. end
  55.  
  56. local function onUpdate()
  57.  
  58. end
  59.  
  60. RunService:BindToRenderStep('Control', Enum.RenderPriority.Input.Value, onUpdate)
  61.  
  62. ContextActionService:BindAction('Left', onLeft, true, 'a', Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
  63. ContextActionService:BindAction('Right', onRight, true, 'd', Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
  64. ContextActionService:BindAction('Jump', onJump, true, 'w', Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
  65. local player = game.Players.LocalPlayer
  66. local RunService = game:GetService('RunService')
  67. local ContextActionService = game:GetService('ContextActionService')
  68.  
  69. local jumping = false
  70. local leftValue, rightValue = 0, 0
  71.  
  72. local function onLeft(actionName, inputState)
  73. if inputState == Enum.UserInputState.Begin then
  74. leftValue = 1
  75. elseif inputState == Enum.UserInputState.End then
  76. leftValue = 0
  77. end
  78. end
  79.  
  80. local function onRight(actionName, inputState)
  81. if inputState == Enum.UserInputState.Begin then
  82. rightValue = 1
  83. elseif inputState == Enum.UserInputState.End then
  84. rightValue = 0
  85. end
  86. end
  87.  
  88. local function onJump(actionName, inputState)
  89. if inputState == Enum.UserInputState.Begin then
  90. jumping = true
  91. elseif inputState == Enum.UserInputState.End then
  92. jumping = false
  93. end
  94. end
  95.  
  96. local function onUpdate()
  97. if player.Character and player.Character:FindFirstChild('Humanoid') then
  98. if jumping then
  99. player.Character.Humanoid.Jump = true
  100. end
  101. local moveDirection = rightValue - leftValue
  102. player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
  103. end
  104. end
Add Comment
Please, Sign In to add comment