Advertisement
KrYn0MoRe

freecam v1.5

May 22nd, 2020
4,383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.74 KB | None | 0 0
  1. script.Parent = nil
  2.  
  3. local plr = owner
  4.  
  5. local char = plr.Character
  6. local head
  7. if char then
  8.     head = char:FindFirstChild("Head")
  9. end
  10.  
  11. local remote,ls
  12.  
  13. local lpos = CFrame.new()
  14. local lrot = CFrame.Angles(0,0,0)
  15.  
  16. if head then
  17.     lpos = head.CFrame
  18. end
  19.  
  20. --//=================================\\
  21. --|| SAZERENOS' ARTIFICIAL HEARTBEAT
  22. --\\=================================//
  23.  
  24. ArtificialHB = Instance.new("BindableEvent", script)
  25. ArtificialHB.Name = "ArtificialHB"
  26.  
  27. script:WaitForChild("ArtificialHB")
  28.  
  29. frame = (1/60)
  30. tf = 0
  31. allowframeloss = false
  32. tossremainder = false
  33. lastframe = tick()
  34. script.ArtificialHB:Fire()
  35.  
  36. game:GetService("RunService").Heartbeat:connect(function(s, p)
  37.     tf = tf + s
  38.     if tf >= frame then
  39.         if allowframeloss then
  40.             script.ArtificialHB:Fire()
  41.             lastframe = tick()
  42.         else
  43.             for i = 1, math.floor(tf / frame) do
  44.                 script.ArtificialHB:Fire()
  45.             end
  46.         lastframe = tick()
  47.         end
  48.         if tossremainder then
  49.             tf = 0
  50.         else
  51.             tf = tf - frame * math.floor(tf / frame)
  52.         end
  53.     end
  54. end)
  55.  
  56. function Swait(NUMBER)
  57.     if NUMBER == 0 or NUMBER == nil then
  58.         ArtificialHB.Event:wait()
  59.     else
  60.         for i = 1, NUMBER do
  61.             ArtificialHB.Event:wait()
  62.         end
  63.     end
  64. end
  65.  
  66. --//=================================\\
  67. --\\=================================//
  68.  
  69. function create_char()
  70.     if not char or not char.Parent then
  71.         char = Instance.new("Model")
  72.         char.Name = plr.Name
  73.     --end
  74.     --if not head or not head.Parent then
  75.         head = Instance.new("Part")
  76.         head.Name = (plr.Name .. "Freecam Head")
  77.         head.Parent = char
  78.         head.Transparency = 1
  79.         head.Position = lpos.Position
  80.         head.Size = Vector3.new(0.05, 0.05, 0.05)
  81.         head.Anchored = true
  82.         head.CanCollide = false
  83.         head.Locked = true
  84.         head.Massless = true
  85.         head.ChildAdded:Connect(function(v)
  86.             if v:IsA("SphereHandleAdornment") or v:IsA("ConeHandleAdornment") or v:IsA("CylinderHandleAdornment") then else
  87.                 v:Destroy()
  88.             end
  89.         end)
  90.         local ConeHandleAdornment0 = Instance.new("ConeHandleAdornment")
  91.         local CylinderHandleAdornment1 = Instance.new("CylinderHandleAdornment")
  92.         local SphereHandleAdornment2 = Instance.new("SphereHandleAdornment")
  93.         ConeHandleAdornment0.Parent = head
  94.         ConeHandleAdornment0.Color = BrickColor.new("Really red")
  95.         ConeHandleAdornment0.Transparency = 0.5
  96.         ConeHandleAdornment0.Radius = 0.3
  97.         ConeHandleAdornment0.Color3 = Color3.new(1, 0, 0)
  98.         ConeHandleAdornment0.Adornee = head
  99.         ConeHandleAdornment0.AlwaysOnTop = true
  100.         ConeHandleAdornment0.SizeRelativeOffset = Vector3.new(0, 0, -55)
  101.         ConeHandleAdornment0.Height = 0.8
  102.         CylinderHandleAdornment1.Parent = head
  103.         CylinderHandleAdornment1.Color = BrickColor.new("Really red")
  104.         CylinderHandleAdornment1.Transparency = 0.5
  105.         CylinderHandleAdornment1.Radius = 0.15
  106.         CylinderHandleAdornment1.Color3 = Color3.new(1, 0, 0)
  107.         CylinderHandleAdornment1.Adornee = head
  108.         CylinderHandleAdornment1.AlwaysOnTop = true
  109.         CylinderHandleAdornment1.SizeRelativeOffset = Vector3.new(0, 0, 5)
  110.         CylinderHandleAdornment1.Height = 3
  111.         SphereHandleAdornment2.Parent = head
  112.         SphereHandleAdornment2.Color = BrickColor.new("Really red")
  113.         SphereHandleAdornment2.Transparency = 0.7
  114.         SphereHandleAdornment2.Color3 = Color3.new(1, 0, 0)
  115.         SphereHandleAdornment2.Adornee = head
  116.     --end
  117.     --if not head:FindFirstChildOfClass('BillboardGui') then
  118.         local BillboardGui0 = Instance.new("BillboardGui")
  119.         local TextBox1 = Instance.new("TextBox")
  120.         BillboardGui0.Parent = head
  121.         BillboardGui0.Size = UDim2.new(0, 200, 1, 0)
  122.         BillboardGui0.Active = true
  123.         BillboardGui0.ClipsDescendants = true
  124.         BillboardGui0.AlwaysOnTop = true
  125.         TextBox1.Name = "name"
  126.         TextBox1.Parent = BillboardGui0
  127.         TextBox1.Size = UDim2.new(1, 0, 1, 0)
  128.         TextBox1.BackgroundColor = BrickColor.new("Institutional white")
  129.         TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
  130.         TextBox1.BackgroundTransparency = 1
  131.         TextBox1.BorderSizePixel = 0
  132.         TextBox1.ZIndex = 2
  133.         TextBox1.Font = Enum.Font.SourceSansBold
  134.         TextBox1.FontSize = Enum.FontSize.Size14
  135.         TextBox1.Text = plr.Name
  136.         TextBox1.TextColor = BrickColor.new("Institutional white")
  137.         TextBox1.TextColor3 = Color3.new(1, 1, 1)
  138.         TextBox1.TextScaled = true
  139.         TextBox1.TextSize = 14
  140.         TextBox1.TextStrokeTransparency = 0
  141.         TextBox1.TextWrap = true
  142.         TextBox1.TextWrapped = true
  143.     end
  144.     char.Parent = workspace
  145.     plr.Character = char
  146. end
  147.  
  148. function create_nls_remote()
  149.     if plr then else return end
  150.     if not remote or not remote.Parent then
  151.         remote = Instance.new("RemoteEvent")
  152.         remote.Parent = plr['PlayerGui']
  153.         remote.OnServerEvent:Connect(function(lplr,pos,_lrot)
  154.             if (plr == lplr) then else return end
  155.             if pos then
  156.                 lpos = pos
  157.             end
  158.             if _lrot then
  159.                 lrot = _lrot
  160.             end
  161.         end)
  162.     end
  163.     if not ls or not ls.Parent then
  164.         NLS([[
  165.         local plr = game:GetService("Players").LocalPlayer
  166.         local char = plr.Character
  167.         local head
  168.         if char then
  169.             head = char:FindFirstChild("Head")
  170.         end
  171.        
  172.         local RS = game:GetService("RunService")
  173.         local TS = game:GetService("TweenService")
  174.         local UIS = game:GetService("UserInputService")
  175.        
  176.         local remote = script.parent
  177.        
  178.         local camera = workspace.CurrentCamera
  179.         camera.CameraType = Enum.CameraType.Custom
  180.         plr.CameraMode = Enum.CameraMode.LockFirstPerson
  181.        
  182.         local moving = {}
  183.         local mv = 0
  184.         local max = 0.8
  185.         local smooth =  0.1
  186.         local lpos = CFrame.new()
  187.         local lrot = CFrame.Angles(camera.CFrame:toEulerAnglesXYZ())
  188.        
  189.         if head then
  190.             lpos = head.CFrame
  191.         end
  192.        
  193.         local fake_head
  194.        
  195.         function make_head()
  196.             if fake_head then fake_head:Destroy(); end;
  197.             fake_head = Instance.new("Part")
  198.             fake_head.Name = (plr.Name .. "Freecam Head")
  199.             fake_head.Parent = workspace
  200.             fake_head.Transparency = 1
  201.             fake_head.Position = lpos.Position
  202.             fake_head.Size = Vector3.new(0.05, 0.05, 0.05)
  203.             fake_head.Anchored = true
  204.             fake_head.CanCollide = false
  205.             fake_head.Locked = true
  206.             fake_head.Massless = true
  207.         end
  208.        
  209.         UIS.InputBegan:Connect(function(Input, Core)
  210.             if not Core then else return end
  211.             local mode = true
  212.             if Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode then
  213.                 if Input.KeyCode == Enum.KeyCode.W then
  214.                     moving['w'] = mode
  215.                 elseif Input.KeyCode == Enum.KeyCode.A then
  216.                     moving['a'] = mode
  217.                 elseif Input.KeyCode == Enum.KeyCode.S then
  218.                     moving['s'] = mode
  219.                 elseif Input.KeyCode == Enum.KeyCode.D then
  220.                     moving['d'] = mode
  221.                 elseif Input.KeyCode == Enum.KeyCode.Space then
  222.                     moving['space'] = mode
  223.                 elseif Input.KeyCode == Enum.KeyCode.LeftControl then
  224.                     moving['control'] = mode
  225.                 elseif Input.KeyCode == Enum.KeyCode.LeftShift then
  226.                     moving['shift'] = mode
  227.                 end
  228.             end
  229.         end)
  230.        
  231.         UIS.InputChanged:Connect(function(Input, Core)
  232.             if not Core then else return end
  233.             local mode = true
  234.             if Input.UserInputType == Enum.UserInputType.MouseWheel then
  235.                 local cfv = CFrame.new(0,0,-(max*10*1.5)*Input.Position.Z)
  236.                 if head then
  237.                     lrot = CFrame.Angles(camera.CFrame:toEulerAnglesXYZ())
  238.                 end
  239.                 lpos = (CFrame.new(lpos.p)*lrot)*cfv
  240.                 if fake_head then
  241.                     moveto(lpos,0.5)
  242.                 end
  243.             end
  244.         end)
  245.        
  246.         UIS.InputEnded:Connect(function(Input, Core)
  247.             if not Core then else return end
  248.             local mode = false
  249.             if Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode then
  250.                 if Input.KeyCode == Enum.KeyCode.W then
  251.                     moving['w'] = mode
  252.                 elseif Input.KeyCode == Enum.KeyCode.A then
  253.                     moving['a'] = mode
  254.                 elseif Input.KeyCode == Enum.KeyCode.S then
  255.                     moving['s'] = mode
  256.                 elseif Input.KeyCode == Enum.KeyCode.D then
  257.                     moving['d'] = mode
  258.                 elseif Input.KeyCode == Enum.KeyCode.Space then
  259.                     moving['space'] = mode
  260.                 elseif Input.KeyCode == Enum.KeyCode.LeftControl then
  261.                     moving['control'] = mode
  262.                 elseif Input.KeyCode == Enum.KeyCode.LeftShift then
  263.                     moving['shift'] = mode
  264.                 end
  265.             end
  266.         end)
  267.        
  268.         spawn(function()
  269.             RS.RenderStepped:Connect(function()
  270.                 if not fake_head or not fake_head.Parent then
  271.                     make_head()
  272.                 end
  273.                 if lpos ~= CFrame.new() then
  274.                     remote:FireServer(lpos,lrot)
  275.                 end
  276.                 if fake_head then
  277.                     fake_head.Anchored = true
  278.                     fake_head.CanCollide = false
  279.                     fake_head.Massless = false
  280.                     camera.CameraSubject = fake_head
  281.                     fake_head:ClearAllChildren()
  282.                 end
  283.                 if not char or not char.Parent or not head or not head.Parent then
  284.                     char = plr.Character
  285.                     if char then
  286.                         head = char:FindFirstChild(plr.Name .. "Freecam Head")
  287.                         if head then
  288.                             camera.CFrame = lpos -- CFrame.new(head.Position)*lrot
  289.                         end
  290.                     end
  291.                 end
  292.                 if head then
  293.                     head.Transparency = 1
  294.                     for i,v in pairs(head:GetChildren()) do
  295.                         if v:IsA("SphereHandleAdornment") or v:IsA("ConeHandleAdornment") or v:IsA("CylinderHandleAdornment") then
  296.                             v.Visible = false
  297.                         end
  298.                         if v:IsA("BillboardGui") or v:IsA("SurfaceGui") then
  299.                             v.Enabled = false
  300.                         end
  301.                         if v:IsA("BasePart") then
  302.                             v.Transparency = 1
  303.                         end
  304.                     end
  305.                 end
  306.             end)
  307.         end)
  308.        
  309.         function moveto(cf,s)
  310.             game:GetService("TweenService"):Create(fake_head,TweenInfo.new(s),{CFrame = cf}):Play()
  311.         end
  312.        
  313.         RS.RenderStepped:Connect(function()
  314.             local cfv = CFrame.new()
  315.             local raw_cfv = CFrame.new()
  316.             local pressing = false
  317.             local shifting = false
  318.             local fell = false
  319.             for key,mode in pairs(moving) do
  320.                 if key and mode == true then
  321.                     pressing = true
  322.                     if key == 'shift' then
  323.                         shifting = true
  324.                     end
  325.                 end
  326.             end
  327.             if pressing then
  328.                 if shifting then
  329.                     mv = mv + (smooth/4)
  330.                     if mv > (max/4) then
  331.                         mv = (max/4)
  332.                     end
  333.                 elseif not shifting then
  334.                     mv = mv + smooth
  335.                     if mv > max then
  336.                         mv = max
  337.                     end
  338.                 end
  339.             elseif not pressing then
  340.                 mv = mv - (smooth*2)
  341.                 if 0 > mv then
  342.                     mv = 0
  343.                 end
  344.             end
  345.             for key,mode in pairs(moving) do
  346.                 if key and mode == true then
  347.                     if key == 'w' then
  348.                         cfv = cfv*CFrame.new(0,0,-mv)
  349.                     elseif key == 'a' then
  350.                         cfv = cfv*CFrame.new(-mv,0,0)
  351.                     elseif key == 's' then
  352.                         cfv = cfv*CFrame.new(0,0,mv)
  353.                     elseif key == 'd' then
  354.                         cfv = cfv*CFrame.new(mv,0,0)
  355.                     elseif key == 'space' then
  356.                         raw_cfv = raw_cfv*CFrame.new(0,mv,0)
  357.                     elseif key == 'control' then
  358.                         raw_cfv = raw_cfv*CFrame.new(0,-mv,0)
  359.                     end
  360.                 end
  361.             end
  362.             if head then
  363.                 lrot = CFrame.Angles(camera.CFrame:toEulerAnglesXYZ())
  364.             end
  365.             if fake_head and (workspace.FallenPartsDestroyHeight + 30) > fake_head.Position.Y then
  366.                 fell = true
  367.                 fake_head.Position = Vector3.new(fake_head.Position.X,10,fake_head.Position.Z)
  368.                 lpos = ((CFrame.new(fake_head.Position)*raw_cfv)*lrot)*cfv
  369.             end
  370.             if not fell then
  371.                 lpos = ((CFrame.new(lpos.p)*raw_cfv)*lrot)*cfv
  372.             end
  373.             if fake_head then
  374.                 moveto(lpos,0.5)
  375.             end
  376.             wait(0.1)
  377.         end)
  378.         ]],remote)
  379.         ls = remote:FindFirstChildOfClass('LocalScript')
  380.     end
  381. end
  382.  
  383. if plr.Character then
  384.     plr.Character:Destroy()
  385. end
  386.  
  387. function moveto(cf,s)
  388.     game:GetService("TweenService"):Create(head,TweenInfo.new(s),{CFrame = cf}):Play()
  389. end
  390.  
  391. spawn(function()
  392.     while wait(0.1) do
  393.         create_nls_remote()
  394.     end
  395. end)
  396.  
  397. warn([[
  398. = FreeCam v1.5 =
  399. = Made by KrYn0MoRe =
  400. == CONTROLS ==
  401. W - Foward
  402. A - Left
  403. S - Backward
  404. D - Right
  405. Left Control - Down
  406. Space - Up
  407. Scroll Up - Forward
  408. Scroll Down - Backward
  409. ]])
  410.  
  411. while true do
  412.     create_char()
  413.     local fell = false
  414.     if head and (workspace.FallenPartsDestroyHeight + 30) > head.Position.Y then
  415.         fell = true
  416.         head.Position = Vector3.new(head.Position.X,10,head.Position.Z)
  417.     end
  418.     if head and not fell then
  419.         head.Anchored = true
  420.         head.CanCollide = false
  421.         head.Massless = false
  422.         moveto(lpos,0.5)
  423.     end
  424.     Swait()
  425. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement