Advertisement
Guest User

CameraScript

a guest
Apr 8th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2.  
  3. local camera = workspace.CurrentCamera
  4. local player = game.Players.LocalPlayer
  5.  
  6. local CAMERA_OFFSET = Vector3.new(-1,90,0)
  7.  
  8. camera.CameraType = Enum.CameraType.Scriptable
  9.  
  10. local function onRenderStep()
  11.    
  12.     if player.Character then
  13.         local playerPosition = player.Character.HumanoidRootPart.Position
  14.         local cameraPosition = playerPosition + CAMERA_OFFSET
  15.        
  16.         --Makes the camera follow player
  17.         camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
  18.     end
  19.    
  20. end
  21.  
  22. RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement