Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local zoom = (-30)
- local yshift = 5
- -- LocalScript instance inside the StarterGui
- local c = Workspace.CurrentCamera
- local p = Game.Players.LocalPlayer
- repeat wait() until p.Character;
- wait(1)
- local char = p.Character
- local s = Game:GetService("RunService");
- local m = p:GetMouse();
- -- settings
- c.CameraType = "Scriptable"
- local directlybehind = char.Head.Position + Vector3.new(0,0,zoom) --+ (char.Torso.CFrame.lookVector * -10)
- local originalDirection = CFrame.new(directlybehind, char.Head.Position).lookVector
- local direction = originalDirection * 1e50
- local shift = --[[char.Torso.CFrame:vectorToWorldSpace(Vector3.new(6,0,0))]] Vector3.new(0,yshift,0);
- local lastY = c.CoordinateFrame.p.y;
- local isJumping = false;
- --[[
- char.Humanoid.Changed:connect(function(prop)
- if prop == "Jump" then
- isJumping = true;
- coroutine.wrap(function()
- wait(2)
- isJumping = false;
- end)()
- end
- end)]]
- function GetDistanceToFloor()
- local r = Ray.new(char.Head.Position, Vector3.new(0,-500,0));
- local part,point = Workspace:FindPartOnRay(r, char)
- if point then
- return (char.Head.Position - point).magnitude
- end
- return 5
- end
- -- while loop to set camera coordinate frame
- s.RenderStepped:connect(function()
- if GetDistanceToFloor() < 4.6 then -- touching a floor (actual value is 4.5)
- directlybehind = char.Head.Position + Vector3.new(0,0,zoom)
- lastY = c.CoordinateFrame.p.y
- else
- directlybehind = Vector3.new(char.Head.Position.X, lastY, char.Head.Position.Z) + Vector3.new(0,0,zoom)
- end
- c.CoordinateFrame = CFrame.new(directlybehind + shift, char.Head.Position);
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement