Advertisement
StefanBashkir

ROBLOX Over-the-Shoulder view

Feb 10th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. -- LocalScript instance inside the StarterGui
  2. local c = Workspace.CurrentCamera
  3. local p = Game.Players.LocalPlayer
  4. local char = p.Character
  5. local s = Game:GetService("RunService");
  6. local m = p:GetMouse();
  7.  
  8. -- settings
  9. c.CameraType = "Scriptable"
  10.  
  11. -- while loop to set camera coordinate frame
  12. s.RenderStepped:connect(function()
  13.     local directlybehind = char.Torso.Position + (char.Torso.CFrame.lookVector * -8)
  14.     local shift = char.Torso.CFrame:vectorToWorldSpace(Vector3.new(4,0,0)) + Vector3.new(0,3,0);
  15.     local lookat = char.Torso.Position + char.Torso.CFrame.lookVector * 1e50
  16.     c.CoordinateFrame = CFrame.new(directlybehind + shift, lookat);
  17. end)
  18.  
  19. m.Move:connect(function()
  20.     char.Torso.CFrame = CFrame.new(char.Torso.Position,
  21.         Vector3.new(m.Hit.p.x, char.Torso.Position.Y, m.Hit.p.z));
  22. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement