Advertisement
Guest User

s4

a guest
Sep 15th, 2019
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.58 KB | None | 0 0
  1. warn("Classy Code's FreeCam Script Loaded")warn("Left Shift + P to use")function sandbox(a,b)local c=getfenv(b)local d=setmetatable({},{__index=function(self,e)if e=="script"then return a else return c[e]end end})setfenv(b,d)return b end;cors={}mas=Instance.new("Model",game:GetService("Lighting"))LocalScript0=Instance.new("LocalScript")LocalScript0.Name="FreecamScript"LocalScript0.Parent=mas;table.insert(cors,sandbox(LocalScript0,function()local f=math.pi;local g=math.abs;local h=math.clamp;local i=math.exp;local j=math.rad;local k=math.sign;local l=math.sqrt;local m=math.tan;local n=game:GetService("ContextActionService")local o=game:GetService("Players")local p=game:GetService("RunService")local q=game:GetService("StarterGui")local r=game:GetService("UserInputService")local s=game:GetService("Workspace")local t=o.LocalPlayer;if not t then o:GetPropertyChangedSignal("LocalPlayer"):Wait()t=o.LocalPlayer end;local u=s.CurrentCamera;s:GetPropertyChangedSignal("CurrentCamera"):Connect(function()local v=s.CurrentCamera;if v then u=v end end)local w=Enum.ContextActionPriority.Low.Value;local x=Enum.ContextActionPriority.High.Value;local y={Enum.KeyCode.LeftShift,Enum.KeyCode.P}local z=Vector3.new(1,1,1)*64;local A=Vector2.new(0.75,1)*8;local B=300;local C=j(90)local D=1.5;local E=1.0;local F=4.0;local G={}do G.__index=G;function G.new(H,I)local self=setmetatable({},G)self.f=H;self.p=I;self.v=I*0;return self end;function G:Update(J,K)local L=self.f*2*f;local M=self.p;local N=self.v;local O=K-M;local P=i(-L*J)local Q=K+(N*J-O*(L*J+1))*P;local R=(L*J*(O*L-N)+N)*P;self.p=Q;self.v=R;return Q end;function G:Reset(I)self.p=I;self.v=I*0 end end;local S=Vector3.new()local T=Vector2.new()local U=0;local V=G.new(D,Vector3.new())local W=G.new(E,Vector2.new())local X=G.new(F,0)local Y={}do local Z;do local _=2.0;local a0=0.15;local function a1(a2)return(i(_*a2)-1)/(i(_)-1)end;local function a3(a2)return a1((a2-a0)/(1-a0))end;function Z(a2)return k(a2)*h(a3(g(a2)),0,1)end end;local a4={ButtonX=0,ButtonY=0,DPadDown=0,DPadUp=0,ButtonL2=0,ButtonR2=0,Thumbstick1=Vector2.new(),Thumbstick2=Vector2.new()}local a5={W=0,A=0,S=0,D=0,E=0,Q=0,U=0,H=0,J=0,K=0,I=0,Y=0,Up=0,Down=0,LeftShift=0,RightShift=0}local a6={Delta=Vector2.new(),MouseWheel=0}local a7=Vector3.new(1,1,1)local a8=Vector3.new(1,1,1)local a9=Vector2.new(1,1)*f/64;local aa=Vector2.new(1,1)*f/8;local ab=1.0;local ac=0.25;local ad=0.75;local ae=0.25;local af=1;function Y.Vel(J)af=h(af+J*(a5.Up-a5.Down)*ad,0.01,4)local ag=Vector3.new(Z(a4.Thumbstick1.x),Z(a4.ButtonR2)-Z(a4.ButtonL2),Z(-a4.Thumbstick1.y))*a7;local ah=Vector3.new(a5.D-a5.A+a5.K-a5.H,a5.E-a5.Q+a5.I-a5.Y,a5.S-a5.W+a5.J-a5.U)*a8;local ai=r:IsKeyDown(Enum.KeyCode.LeftShift)or r:IsKeyDown(Enum.KeyCode.RightShift)return(ag+ah)*af*(ai and ae or 1)end;function Y.Pan(J)local ag=Vector2.new(Z(a4.Thumbstick2.y),Z(-a4.Thumbstick2.x))*aa;local aj=a6.Delta*a9;a6.Delta=Vector2.new()return ag+aj end;function Y.Fov(J)local ag=(a4.ButtonX-a4.ButtonY)*ac;local aj=a6.MouseWheel*ab;a6.MouseWheel=0;return ag+aj end;do local function ak(al,am,an)a5[an.KeyCode.Name]=am==Enum.UserInputState.Begin and 1 or 0;return Enum.ContextActionResult.Sink end;local function ao(al,am,an)a4[an.KeyCode.Name]=am==Enum.UserInputState.Begin and 1 or 0;return Enum.ContextActionResult.Sink end;local function ap(al,am,an)local aq=an.Delta;a6.Delta=Vector2.new(-aq.y,-aq.x)return Enum.ContextActionResult.Sink end;local function ar(al,am,an)a4[an.KeyCode.Name]=an.Position;return Enum.ContextActionResult.Sink end;local function as(al,am,an)a4[an.KeyCode.Name]=an.Position.z;return Enum.ContextActionResult.Sink end;local function at(al,am,an)a6[an.UserInputType.Name]=-an.Position.z;return Enum.ContextActionResult.Sink end;local function au(av)for e,aw in pairs(av)do av[e]=aw*0 end end;function Y.StartCapture()n:BindActionAtPriority("FreecamKeyboard",ak,false,x,Enum.KeyCode.W,Enum.KeyCode.U,Enum.KeyCode.A,Enum.KeyCode.H,Enum.KeyCode.S,Enum.KeyCode.J,Enum.KeyCode.D,Enum.KeyCode.K,Enum.KeyCode.E,Enum.KeyCode.I,Enum.KeyCode.Q,Enum.KeyCode.Y,Enum.KeyCode.Up,Enum.KeyCode.Down)n:BindActionAtPriority("FreecamMousePan",ap,false,x,Enum.UserInputType.MouseMovement)n:BindActionAtPriority("FreecamMouseWheel",at,false,x,Enum.UserInputType.MouseWheel)n:BindActionAtPriority("FreecamGamepadButton",ao,false,x,Enum.KeyCode.ButtonX,Enum.KeyCode.ButtonY)n:BindActionAtPriority("FreecamGamepadTrigger",as,false,x,Enum.KeyCode.ButtonR2,Enum.KeyCode.ButtonL2)n:BindActionAtPriority("FreecamGamepadThumbstick",ar,false,x,Enum.KeyCode.Thumbstick1,Enum.KeyCode.Thumbstick2)end;function Y.StopCapture()af=1;au(a4)au(a5)au(a6)n:UnbindAction("FreecamKeyboard")n:UnbindAction("FreecamMousePan")n:UnbindAction("FreecamMouseWheel")n:UnbindAction("FreecamGamepadButton")n:UnbindAction("FreecamGamepadTrigger")n:UnbindAction("FreecamGamepadThumbstick")end end end;local function ax(ay)local az=0.1;local aA=u.ViewportSize;local aB=2*m(U/2)local aC=aA.x/aA.y*aB;local aD=ay.rightVector;local aE=ay.upVector;local aF=ay.lookVector;local aG=Vector3.new()local aH=512;for a2=0,1,0.5 do for aI=0,1,0.5 do local aJ=(a2-0.5)*aC;local aK=(aI-0.5)*aB;local O=aD*aJ-aE*aK+aF;local aL=ay.p+O*az;local aM,aN=s:FindPartOnRay(Ray.new(aL,O.unit*aH))local aO=(aN-aL).magnitude;if aH>aO then aH=aO;aG=O.unit end end end;return aF:Dot(aG)*aH end;local function aP(J)local aQ=V:Update(J,Y.Vel(J))local aR=W:Update(J,Y.Pan(J))local aS=X:Update(J,Y.Fov(J))local aT=l(m(j(70/2))/m(j(U/2)))U=h(U+aS*B*J/aT,1,120)T=T+aR*A*J/aT;T=Vector2.new(h(T.x,-C,C),T.y%(2*f))local aU=CFrame.new(S)*CFrame.fromOrientation(T.x,T.y,0)*CFrame.new(aQ*z*J)S=aU.p;u.CFrame=aU;u.Focus=aU*CFrame.new(0,0,-ax(aU))u.FieldOfView=U end;local aV={}do local aW;local aX;local aY;local aZ;local aU;local a_;local b0={}local b1={Backpack=true,Chat=true,Health=true,PlayerList=true}local b2={BadgesNotificationsActive=true,PointsNotificationsActive=true}function aV.Push()for b3 in pairs(b1)do b1[b3]=q:GetCoreGuiEnabled(Enum.CoreGuiType[b3])q:SetCoreGuiEnabled(Enum.CoreGuiType[b3],false)end;for b3 in pairs(b2)do b2[b3]=q:GetCore(b3)q:SetCore(b3,false)end;local b4=t:FindFirstChildOfClass("PlayerGui")if b4 then for aM,b5 in pairs(b4:GetChildren())do if b5:IsA("ScreenGui")and b5.Enabled then b0[#b0+1]=b5;b5.Enabled=false end end end;a_=u.FieldOfView;u.FieldOfView=70;aY=u.CameraType;u.CameraType=Enum.CameraType.Custom;aU=u.CFrame;aZ=u.Focus;aX=r.MouseIconEnabled;r.MouseIconEnabled=false;aW=r.MouseBehavior;r.MouseBehavior=Enum.MouseBehavior.Default end;function aV.Pop()for b3,b6 in pairs(b1)do q:SetCoreGuiEnabled(Enum.CoreGuiType[b3],b6)end;for b3,b6 in pairs(b2)do q:SetCore(b3,b6)end;for aM,b5 in pairs(b0)do if b5.Parent then b5.Enabled=true end end;u.FieldOfView=a_;a_=nil;u.CameraType=aY;aY=nil;u.CFrame=aU;aU=nil;u.Focus=aZ;aZ=nil;r.MouseIconEnabled=aX;aX=nil;r.MouseBehavior=aW;aW=nil end end;local function b7()local aU=u.CFrame;T=Vector2.new(aU:toEulerAnglesYXZ())S=aU.p;U=u.FieldOfView;V:Reset(Vector3.new())W:Reset(Vector2.new())X:Reset(0)aV.Push()p:BindToRenderStep("Freecam",Enum.RenderPriority.Camera.Value,aP)Y.StartCapture()end;local function b8()Y.StopCapture()p:UnbindFromRenderStep("Freecam")aV.Pop()end;do local b9=false;local function ba()if b9 then b8()else b7()end;b9=not b9 end;local function bb(bc)for bd=1,#bc-1 do if not r:IsKeyDown(bc[bd])then return end end;ba()end;local function be(al,am,an)if am==Enum.UserInputState.Begin then if an.KeyCode==y[#y]then bb(y)end end;return Enum.ContextActionResult.Pass end;n:BindActionAtPriority("FreecamToggle",be,false,w,y[#y])end end))for bd,aw in pairs(mas:GetChildren())do aw.Parent=game:GetService("Players").LocalPlayer.Character;pcall(function()aw:MakeJoints()end)end;mas:Destroy()for bd,aw in pairs(cors)do spawn(function()pcall(aw)end)end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement