local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local plr_char = player.Character
local plr_Humanoid = plr_char:FindFirstChildOfClass("Humanoid")
local control = {F = false, B = false, L = false, R = false}
local last = {F = false, B = false, L = false, R = false}
local lmb = false
local rmb = false
local frm = 0
local step = 0
local max_step = 4
local Bob_updater
local Bobbing = false
local bv = Vector3.new(0, 0, 0)
local update_t = 0
local update_tick = 1/30
local update_max = 3
local camera = workspace.CurrentCamera
local cam_pos = Vector3.new()
local cam_rot = Vector3.new()
local cam_fov = 0
local old_pos = Vector3.new()
local old_rot = Vector3.new()
local old_fov = 0
local cam_dif = Vector3.new()
local cam_sensitivity = 0.02
local CFrame_lookUp = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 1, 0)
local CFrame_lookDown = CFrame.new(0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0)
local CFrame_lookLeft = CFrame.new(0, 0, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
local CFrame_lookRight = CFrame.new(0, 0, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
function Create_Part()
local p = Instance.new("Part")
p.Name = "Bob_Part"
p.CFrame = plr_char.Torso.CFrame
p.Size = Vector3.new(1, 1, 1)
p.Anchored = true
p.CanCollide = false
p.BottomSurface = 0
p.TopSurface = 0
p.Material = "Neon"
p.BrickColor = BrickColor.new("Lime green")
p.Parent = plr_char
end
function Remove_Part()
local p = plr_char:FindFirstChild("Bob_Part")
if p then
p:Destroy()
end
end
player.CharacterAdded:connect(function()
plr_char = player.Character
plr_Humanoid = plr_char:FindFirstChildOfClass("Humanoid")
workspace.CurrentCamera.CameraSubject = plr_char.Head
end)
player.CharacterRemoving:connect(function()
Remove_Part()
end)
local function Get_Part_Pos()
local p = plr_char:FindFirstChild("Bob_Part")
if p then
return p.CFrame
else
return nil
end
end
local function Set_Part_Pos(cf)
local p = plr_char:FindFirstChild("Bob_Part")
if p and cf then
p.CFrame = cf
end
end
local function Look(rot)
if rot then
local now = tick()
local diff = now - update_t
if diff >= update_tick and update_t ~= 0 then
local max_dif = update_tick*update_max
local dif_f = diff/max_dif
if dif_f > 1 then
dif_f = 1
end
local cf = old_rot:lerp(rot, dif_f)
workspace.CurrentCamera.CFrame = cf
else
workspace.CurrentCamera.CFrame = rot
end
update_t = now
old_rot = workspace.CurrentCamera.CFrame
end
end
local function Move(pos)
if pos then
local now = tick()
local diff = now - update_t
if diff >= update_tick and update_t ~= 0 then
local max_dif = update_tick*update_max
local dif_f = diff/max_dif
if dif_f > 1 then
dif_f = 1
end
local cf = old_pos:lerp(pos, dif_f)
workspace.CurrentCamera.CFrame = cf
else
workspace.CurrentCamera.CFrame = pos
end
update_t = now
old_pos = workspace.CurrentCamera.CFrame
end
end
local function Zoom(fov)
if fov then
local now = tick()
local diff = now - update_t
if diff >= update_tick and update_t ~= 0 then
local max_dif = update_tick*update_max
local dif_f = diff/max_dif
if dif_f > 1 then
dif_f = 1
end
workspace.CurrentCamera.FieldOfView = math.lerp(old_fov, fov, dif_f)
else
workspace.CurrentCamera.FieldOfView = fov
end
update_t = now
old_fov = workspace.CurrentCamera.FieldOfView
end
end
local function Rotate_Cam(input)
if input then
local now = tick()
local diff = now - update_t
if diff >= update_tick and update_t ~= 0 then
local max_dif = update_tick*update_max
local dif_f = diff/max_dif
if dif_f > 1 then
dif_f = 1
end
local cf = old_pos:lerp(input, dif_f)
workspace.CurrentCamera.CFrame = cf
else
workspace.CurrentCamera.CFrame = input
end
update_t = now
old_pos = workspace.CurrentCamera.CFrame
end
end
local function Get_Speed()
return plr_Humanoid.WalkSpeed
end
local function Set_Speed(speed)
plr_Humanoid.WalkSpeed = speed
end
local function Set_Camera(pos, rot, fov)
if pos then
Move(pos)
end
if rot then
Look(rot)
end
if fov then
Zoom(fov)
end
end
local function Get_Camera()
return workspace.CurrentCamera.CFrame, workspace.CurrentCamera.FieldOfView
end
local function Get_Key(key)
return control[key]
end
local function Is_Key(key)
if control[key] ~= nil then
return control[key]
else
return false
end
end
local function Set_Key(key, set)
control[key] = set
end
local function Is_Key_Down(key)
if last[key] == true and control[key] == false then
return true
else
return false
end
end
local function Is_Key_Up(key)
if last[key] == false and control[key] == true then
return true
else
return false
end
end
local function Is_LMB()
return lmb
end
local function Is_RMB()
return rmb
end
local function Set_LMB(set)
lmb = set
end
local function Set_RMB(set)
rmb = set
end
local function Is_LMB_Down()
if last.lmb == true and lmb == false then
return true
else
return false
end
end
local function Is_LMB_Up()
if last.lmb == false and lmb == true then
return true
else
return false
end
end
local function Is_RMB_Down()
if last.rmb == true and rmb == false then
return true
else
return false
end
end
local function Is_RMB_Up()
if last.rmb == false and rmb == true then
return true
else
return false
end
end
local function Get_Frame()
return frm
end
local function Get_Step()
return step
end
local function Is_First_Frame()
if frm == 1 then
return true
else
return false
end
end
local function Is_Last_Frame()
if frm == max_step then
return true
else
return false
end
end
local function Is_Odd_Frame()
if frm%2 == 1 then
return true
else
return false
end
end
local function Is_Even_Frame()
if frm%2 == 0 then
return true
else
return false
end
end
local function Set_Step(set)
step = set
end
local function Get_Max_Step()
return max_step
end
local function Set_Max_Step(set)
max_step = set
end
local function Set_Bob(set)
Bobbing = set
end
local function Get_Bob()
return Bobbing
end
local function Is_Bobbing()
return Bobbing
end
local function Set_Bob_Vector(vect)
if vect then
bv = vect
end
end
local function Get_Bob_Vector()
return bv
end
local function Set_Bob_Updater(func)
if func then
Bob_updater = func
end
end
local function Get_Bob_Updater()
return Bob_updater
end
local function Set_Sensitivity(sens)
if sens then
cam_sensitivity = sens
end
end
local function Get_Sensitivity()
return cam_sensitivity
end
local function Update()
if Bobbing == true then
if Bob_updater then
Bob_updater()
else
print("No Bob updater found")
end
end
frm = frm + 1
if frm >= max_step then
frm = 1
end
if Bobbing == true then
Set_Part_Pos(plr_char.Torso.CFrame + bv)
end
camera = workspace.CurrentCamera
old_pos = camera.CFrame
old_rot = camera.CFrame
old_fov = camera.FieldOfView
Set_Camera(cam_pos, cam_rot, cam_fov)
for i, v in pairs(control) do
last[i] = v
end
end
mouse.KeyDown:connect(function(key)
if key:byte() <= string.byte("Z") and key:byte() >= string.byte("A") then
Set_Key(string.char(key:byte()), true)
elseif key == "f" then
Set_Key("F", true)
elseif key == "b" then
Set_Key("B", true)
elseif key == "l" then
Set_Key("L", true)
elseif key == "r" then
Set_Key("R", true)
elseif key == "q" then
Set_Key("Q", true)
elseif key == "e" then
Set_Key("E", true)
end
end)
mouse.KeyUp:connect(function(key)
if key:byte() <= string.byte("Z") and key:byte() >= string.byte("A") then
Set_Key(string.char(key:byte()), false)
elseif key == "f" then
Set_Key("F", false)
elseif key == "b" then
Set_Key("B", false)
elseif key == "l" then
Set_Key("L", false)
elseif key == "r" then
Set_Key("R", false)
elseif key == "q" then
Set_Key("Q", false)
elseif key == "e" then
Set_Key("E", false)
end
end)
mouse.Button1Down:connect(function()
Set_LMB(true)
end)
mouse.Button1Up:connect(function()
Set_LMB(false)
end)
mouse.Button2Down:connect(function()
Set_RMB(true)
end)
mouse.Button2Up:connect(function()
Set_RMB(false)
end)
mouse.Move:connect(function(dx, dy)
if Bobbing == false then
local up_vect = workspace.CurrentCamera.CFrame.lookVector
local right_vect = workspace.CurrentCamera.CFrame.rightVector
local look_vect = workspace.CurrentCamera.CFrame.lookVector
up_vect = up_vect + right_vect*math.rad(-dy*cam_sensitivity)
right_vect = right_vect*CFrame.new(math.rad(dx*cam_sensitivity), 0, 0):inverse()
look_vect = right_vect + up_vect
local rot_cf = CFrame.new(workspace.CurrentCamera.CFrame.p, workspace.CurrentCamera.CFrame.p + look_vect)
Set_Camera(nil, rot_cf, nil)
--workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.p, workspace.CurrentCamera.CFrame.p + look_vect)
end
end)
local function TP(pos, rot, fov)
Set_Camera(pos, rot, fov)
end
local function Set_Pos(pos)
Set_Camera(pos, nil, nil)
end
local function Set_Rot(rot)
Set_Camera(nil, rot, nil)
end
local function Set_FOV(fov)
Set_Camera(nil, nil, fov)
end
local function Get_FOV()
return workspace.CurrentCamera.FieldOfView
end
local function Get_Pos()
return workspace.CurrentCamera.CFrame
end
local function Get_Rot()
return workspace.CurrentCamera.CFrame
end
local function Get_Look_Vector()
return workspace.CurrentCamera.CFrame.lookVector
end
local function Get_Up_Vector()
return workspace.CurrentCamera.CFrame.upVector
end
local function Get_Right_Vector()
return workspace.CurrentCamera.CFrame.rightVector
end
local function To_View(vect)
return workspace.CurrentCamera:WorldToViewportPoint(vect)
end
local function To_World(vect)
return workspace.CurrentCamera:ViewportToWorldPoint(vect)
end
game:GetService("RunService").RenderStepped:connect(function()
Update()
end)
local function Print_Debug(text)
print("Bhop debug>", text)
end
local function Is_On_Ground()
local ray = Ray.new(workspace.CurrentCamera.CFrame.p, workspace.CurrentCamera.CFrame.p - Vector3.new(0, 0.5, 0))
local part, pos = workspace:FindPartOnRay(ray, workspace.CurrentCamera)
if part then
if part.CanCollide and not part.Anchored then
if (part.Material ~= Enum.Material.Air) and (part.Material ~= Enum.Material.Water) and (part.Material ~= Enum.Material.Slate) and (part.Material ~= Enum.Material.Concrete) and (part.Material ~= Enum.Material.CorrodedMetal) and (part.Material ~= Enum.Material.DiamondPlate) and (part.Material ~= Enum.Material.Grass) and (part.Material ~= Enum.Material.Ice) and (part.Material ~= Enum.Material.Marble) and (part.Material ~= Enum.Material.Granite) and (part.Material ~= Enum.Material.Pebble) and (part.Material ~= Enum.Material.Sand) and (part.Material ~= Enum.Material.SmoothPlastic) and (part.Material ~= Enum.Material.WoodPlanks) and (part.Material ~= Enum.Material.Asphalt) and (part.Material ~= Enum.Material.Brick) and (part.Material ~= Enum.Material.Cobblestone) and (part.Material ~= Enum.Material.CinderBlock) and (part.Material ~= Enum.Material.Glass) and (part.Material ~= Enum.Material.Metal) and (part.Material ~= Enum.Material.Plastic) and (part.Material ~= Enum.Material.Rock) and (part.Material ~= Enum.Material.SmoothMetal) and (part.Material ~= Enum.Material.Fabric) and (part.Material ~= Enum.Material.Foil) and (part.Material ~= Enum.Material.Neon) and (part.Material ~= Enum.Material.Pearl) and (part.Material ~= Enum.Material.Shell) and (part.Material ~= Enum.Material.Solid) and (part.Material ~= Enum.Material.Sponge) and (part.Material ~= Enum.Material.Wood) then
return true
end
end
end
end
local function Get_Local_Speed()
return workspace.CurrentCamera.CFrame.p - last_pos
end
local function Get_Absolute_Speed()
return workspace.CurrentCamera.CFrame.p - last_pos
end
local function Update()
local cam = workspace.CurrentCamera
local up = Get_Up_Vector()
local right = Get_Right_Vector()
local spd = Get_Local_Speed()
local abs_spd = Get_Absolute_Speed()
local vp = To_View(workspace.CurrentCamera.CFrame.p)
if Is_On_Ground() then
if spd.magnitude > 1 then
Print_Debug("You're moving too fast!")
end
if spd.y > 1 then
Print_Debug("You're jumping too high!")
end
if abs_spd.y < 0 then
Print_Debug("You're falling too fast!")
end
if abs_spd.z < 0 and vp.z < 0.5 then
Print_Debug("You're going too slow!")
end
end
last_pos = workspace.CurrentCamera.CFrame.p
end
No one is going to go through an entire 500 lines of code for free. This category is for small snippets of code that are causing errors. Just for future notice.
1 Like
you are totally right, It was a joke by the way