anphu04

I can't see the bottom - free camera script

Jan 3rd, 2019
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.72 KB | None | 0 0
  1. -- 3/1/2019 free camera script by Valualty --
  2. -- twitter: @Valualty --
  3. SPEEDY_DRIFTY = 0.7 -- studs every 1/60 seconds
  4. x_degree = 2.5 -- degrees every 1/60 seconds
  5. y_degree = 1.4 -- degrees every 1/60 seconds
  6. plr = game.Players.LocalPlayer
  7. repeat
  8.     wait()
  9. until plr.Character
  10. mouse = plr:GetMouse()
  11. cam = workspace.CurrentCamera
  12. hum = plr.Character.Humanoid
  13. oldspeed = hum.WalkSpeed
  14. run = game:GetService('RunService')
  15.  
  16.  
  17.  
  18. -----------------------------------------------------------------------
  19. plr.PlayerScripts.CameraScript:Destroy()
  20. game:GetService('UserInputService').MouseBehavior = 'Default'
  21. game:GetService('UserInputService').MouseIconEnabled = true
  22. -----------------------------------------------------------------------
  23.  
  24.  
  25.  
  26. screensize = cam.ViewportSize
  27.  
  28. w,s,a,d,q,e = false,false,false,false,false,false -- position
  29. rr,rl,ru,rd = false,false,false,false -- rotation
  30. ded = false
  31. tog = true
  32.  
  33. pp = Instance.new('Part')
  34. pp.Transparency = 1
  35. pp.TopSurface = 0
  36. pp.BottomSurface = 0
  37. pp.Anchored = true
  38. pp.CanCollide = false
  39. pp.Parent = cam
  40. ll = Instance.new('PointLight')
  41. ll.Range = 60
  42. ll.Brightness = 1
  43. ll.Parent = pp
  44.  
  45. keydown = mouse.KeyDown:Connect(function(key)
  46.     if key == 'w' then w = true end
  47.     if key == 's' then s = true end
  48.     if key == 'a' then a = true end
  49.     if key == 'd' then d = true end
  50.     if key == 'q' then q = true end
  51.     if key == 'e' then e = true end
  52.    
  53.     if hum.Health > 0 then
  54.         if key == string.lower('f') then
  55.             if tog then
  56.                 tog = false
  57.             else
  58.                 tog = true
  59.             end
  60.         end
  61.     end
  62. end)
  63. keyup = mouse.KeyUp:Connect(function(key)
  64.     if key == 'w' then w = false end
  65.     if key == 's' then s = false end
  66.     if key == 'a' then a = false end
  67.     if key == 'd' then d = false end
  68.     if key == 'q' then q = false end
  69.     if key == 'e' then e = false end
  70. end)
  71.  
  72. died = hum.Died:Connect(function()
  73.     ded = true
  74. end)
  75.  
  76. mousemove = mouse.Move:Connect(function()
  77.     x = mouse.X
  78.     y = mouse.Y
  79.     if x / screensize.X <= 0.1 then
  80.         rl = true
  81.     else
  82.         rl = false
  83.     end
  84.     if x / screensize.X >= 0.8 then
  85.         rr = true
  86.     else
  87.         rr = false
  88.     end
  89.     if y / screensize.Y <= 0.15 then
  90.         ru = true
  91.     else
  92.         ru = false
  93.     end
  94.     if y / screensize.Y >= 0.8 then
  95.         rd = true
  96.     else
  97.         rd = false
  98.     end
  99. end)
  100.  
  101. while ded == false do
  102.     if tog == true then
  103.         cam.CameraType = 'Scriptable'
  104.         cam.CameraSubject = pp
  105.         pp.CFrame = cam.CFrame
  106.         hum.WalkSpeed = 0
  107.         if w then
  108.             cam.CFrame = cam.CFrame * CFrame.new(0,0,-SPEEDY_DRIFTY)
  109.         end
  110.         if s then
  111.             cam.CFrame = cam.CFrame * CFrame.new(0,0,SPEEDY_DRIFTY)
  112.         end
  113.         if a then
  114.             cam.CFrame = cam.CFrame * CFrame.new(-SPEEDY_DRIFTY,0,0)
  115.         end
  116.         if d then
  117.             cam.CFrame = cam.CFrame * CFrame.new(SPEEDY_DRIFTY,0,0)
  118.         end
  119.         if q then
  120.             cam.CFrame = cam.CFrame * CFrame.new(0,-SPEEDY_DRIFTY,0)
  121.         end
  122.         if e then
  123.             cam.CFrame = cam.CFrame * CFrame.new(0,SPEEDY_DRIFTY,0)
  124.         end
  125.        
  126.         -- WORKS IN FIRST TRY --
  127.         -- rotating is in global --
  128.         if rl then
  129.             camrot = cam.CFrame - cam.CFrame.p
  130.             cam.CFrame = CFrame.new(cam.CFrame.p) * CFrame.Angles(0, math.rad(x_degree), 0) * camrot
  131.         end
  132.         if rr then
  133.             camrot = cam.CFrame - cam.CFrame.p
  134.             cam.CFrame = CFrame.new(cam.CFrame.p) * CFrame.Angles(0, math.rad(-x_degree), 0) * camrot
  135.         end
  136.         -- rotating x can't be in global --
  137.         if ru then
  138.             cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(y_degree), 0, 0)
  139.         end
  140.         if rd then
  141.             cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(-y_degree), 0, 0)
  142.         end
  143.     else
  144.         hum.WalkSpeed = oldspeed
  145.         cam.CameraType = 'Custom'
  146.         cam.CameraSubject = hum
  147.     end
  148.     run.RenderStepped:Wait()
  149. end
  150. keydown:Disconnect()
  151. keyup:Disconnect()
  152. died:Disconnect()
  153. mousemove:Disconnect()
  154. pp:Destroy()
  155. cam.CameraType = 'Custom'
  156. cam.CameraSubject = hum
Add Comment
Please, Sign In to add comment