as i said the camera bobbing script is the problem but i dont know how to go about it
camera Bobbing Script is the thing that makes my new script not work after death
camera bobbing script:
repeat wait() until game:GetService(“Players”).LocalPlayer.Character ~= nil
local runService = game:GetService(“RunService”)
local input = game:GetService(“UserInputService”)
local players = game:GetService(“Players”)
CanToggleMouse = {allowed = true; activationkey = Enum.KeyCode.T;} – lets you move your mouse around in firstperson
CanViewBody = true – whether you see your body
Sensitivity = 0.2 – anything higher would make looking up and down harder; recommend anything between 0~1
Smoothness = 0.05 – recommend anything between 0~1
FieldOfView = 100 – fov
local clone = script:Clone()
clone.Parent = game.ReplicatedStorage
clone.Name = “SwayClone”
local cam = game.Workspace.CurrentCamera
local player = players.LocalPlayer
local m = player:GetMouse()
m.Icon = “http://www.roblox.com/asset/?id=569021388” – replaces mouse icon
local character = player.Character or player.CharacterAdded:wait()
local humanoidpart = character.HumanoidRootPart
local head = character:WaitForChild(“Head”)
local CamPos,TargetCamPos = cam.CoordinateFrame.p,cam.CoordinateFrame.p
local AngleX,TargetAngleX = 0,0
local AngleY,TargetAngleY = 0,0
local running = true
local freemouse = false
function updatechar()
for _, v in pairs(character:GetChildren())do
if CanViewBody then
if v.Name == 'Head' then
v.LocalTransparencyModifier = 1
v.CanCollide = false
end
else
if v:IsA'Part' or v:IsA'UnionOperation' or v:IsA'MeshPart' then
v.LocalTransparencyModifier = 1
v.CanCollide = false
end
end
if v:IsA'Accessory' then
v:FindFirstChild('Handle').LocalTransparencyModifier = 1
v:FindFirstChild('Handle').CanCollide = false
end
if v:IsA'Hat' then
v:FindFirstChild('Handle').LocalTransparencyModifier = 1
v:FindFirstChild('Handle').CanCollide = false
end
end
end
input.InputChanged:connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
local delta = Vector2.new(inputObject.Delta.x/Sensitivity,inputObject.Delta.y/Sensitivity) * Smoothness
local X = TargetAngleX - delta.y
TargetAngleX = (X >= 80 and 80) or (X <= -80 and -80) or X
TargetAngleY = (TargetAngleY - delta.x) %360
end
end)
input.InputBegan:connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.Keyboard then
if inputObject.KeyCode == CanToggleMouse.activationkey then
if CanToggleMouse.allowed and freemouse == false then
freemouse = true
else
freemouse = false
end
end
end
end)
runService:BindToRenderStep(“cam”, Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
if game.ReplicatedStorage.BoolStorage.ThirdPerson.Switch.Value == false then
if running then
print(“Fp”)
CamPos = CamPos + (TargetCamPos - CamPos) *0.28
AngleX = AngleX + (TargetAngleX - AngleX) *0.35
local dist = TargetAngleY - AngleY
dist = math.abs(dist) > 180 and dist - (dist / math.abs(dist)) * 360 or dist
AngleY = (AngleY + dist *0.35) %360
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = CFrame.new(head.Position)
* CFrame.Angles(0,math.rad(AngleY),0)
* CFrame.Angles(math.rad(AngleX),0,0)
* CFrame.new(0,0.3,0) -- offset
humanoidpart.CFrame=CFrame.new(humanoidpart.Position)*CFrame.Angles(0,math.rad(AngleY),0)
character.Humanoid.AutoRotate = false
else game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default; character.Humanoid.AutoRotate = true
end
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude < 1 then
running = false
else
running = true
if freemouse == true then
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
else
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
end
end
if not CanToggleMouse.allowed then
freemouse = false
end
cam.FieldOfView = FieldOfView
else
if game.ReplicatedStorage.BoolStorage.ThirdPerson.Switch.Value == true then
if running then
print("Thp")
CamPos = CamPos + (TargetCamPos - CamPos) *0.28
AngleX = AngleX + (TargetAngleX - AngleX) *0.35
local dist = TargetAngleY - AngleY
dist = math.abs(dist) > 180 and dist - (dist / math.abs(dist)) * 360 or dist
AngleY = (AngleY + dist *0.35) %360
cam.CameraType = Enum.CameraType.Scriptable
cam.CoordinateFrame = CFrame.new(head.Position)
* CFrame.Angles(0,math.rad(AngleY),0)
* CFrame.Angles(math.rad(AngleX),0,0)
* CFrame.new(2,0.2,6) -- offset
humanoidpart.CFrame=CFrame.new(humanoidpart.Position)*CFrame.Angles(0,math.rad(AngleY),0)
character.Humanoid.AutoRotate = false
else game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default; character.Humanoid.AutoRotate = true
end
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude < 1 then
running = false
else
running = true
if freemouse == true then
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
else
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
end
end
if not CanToggleMouse.allowed then
freemouse = false
end
cam.FieldOfView = FieldOfView
end
end
end)
script that still works but doesnt do anything script:
local Waist = (not IsR6 and Trso:WaitForChild(“Waist”)) --[R6 doesn’t have a waist joint, unfortunately.]
–[[
[Whether rotation follows the camera or the mouse.]
[Useful with tools if true, but camera tracking runs smoother.]
–]]
local MseGuide = false
–[[
[Whether the whole character turns to face the mouse.]
[If set to true, MseGuide will be set to true and both HeadHorFactor and BodyHorFactor will be set to 0]
–]]
local TurnCharacterToMouse = false
–[[
[Horizontal and Vertical limits for head and body tracking.]
[Setting to 0 negates tracking, setting to 1 is normal tracking, and setting to anything higher than 1 goes past real life head/body rotation capabilities.]
–]]
local HeadHorFactor = 1
local HeadVertFactor = 0.6
local BodyHorFactor = 0.0
local BodyVertFactor = 0.0
–[[
[How fast the body rotates.]
[Setting to 0 negates tracking, and setting to 1 is instant rotation. 0.5 is a nice in-between that works with MseGuide on or off.]
[Setting this any higher than 1 causes weird glitchy shaking occasionally.]
–]]
local UpdateSpeed = 0.5
local NeckOrgnC0 = Neck.C0 --[Get the base C0 to manipulate off of.]
local WaistOrgnC0 = (not IsR6 and Waist.C0) --[Get the base C0 to manipulate off of.]
–[Setup]:
Neck.MaxVelocity = 1/3
– Activation]:
if TurnCharacterToMouse == true then
MseGuide = true
HeadHorFactor = 0
BodyHorFactor = 0
end
game:GetService(“RunService”).RenderStepped:Connect(function()
local CamCF = Cam.CoordinateFrame
if Plr.Character.Humanoid.Health > 0 then
print(“Cewl”)
local Head = Body:WaitForChild(“Head”)
if ((IsR6 and Body[“Torso”]) or Body[“UpperTorso”])~=nil and Body[“Head”]~=nil then --[Check for the Torso and Head…]
local TrsoLV = Trso.CFrame.lookVector
local HdPos = Head.CFrame.p
if IsR6 and Neck or Neck and Waist then --[Make sure the Neck still exists.]
if Cam.CameraSubject:IsDescendantOf(Body) or Cam.CameraSubject:IsDescendantOf(Plr) then
local Dist = nil;
local Diff = nil;
if not MseGuide then --[If not tracking the Mouse then get the Camera.]
Dist = (Head.CFrame.p-CamCF.p).magnitude
Diff = Head.CFrame.Y-CamCF.Y
if not IsR6 then --[R6 and R15 Neck rotation C0s are different; R15: X axis inverted and Z is now the Y.]
Neck.C0 = Neck.C0:lerp(NeckOrgnC0Ang((aSin(Diff/Dist)HeadVertFactor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).YHeadHorFactor, 0), UpdateSpeed/2)
Waist.C0 = Waist.C0:lerp(WaistOrgnC0Ang((aSin(Diff/Dist)BodyVertFactor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).YBodyHorFactor, 0), UpdateSpeed/2)
else --[R15s actually have the properly oriented Neck CFrame.]
Neck.C0 = Neck.C0:lerp(NeckOrgnC0Ang(-(aSin(Diff/Dist)HeadVertFactor), 0, -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).YHeadHorFactor),UpdateSpeed/2)
end
else
local Point = Mouse.Hit.p
Dist = (Head.CFrame.p-Point).magnitude
Diff = Head.CFrame.Y-Point.Y
if not IsR6 then
Neck.C0 = Neck.C0:lerp(NeckOrgnC0Ang(-(aTan(Diff/Dist)HeadVertFactor), (((HdPos-Point).Unit):Cross(TrsoLV)).YHeadHorFactor, 0), UpdateSpeed/2)
Waist.C0 = Waist.C0:lerp(WaistOrgnC0Ang(-(aTan(Diff/Dist)BodyVertFactor), (((HdPos-Point).Unit):Cross(TrsoLV)).YBodyHorFactor, 0), UpdateSpeed/2)
else
Neck.C0 = Neck.C0:lerp(NeckOrgnC0Ang((aTan(Diff/Dist)HeadVertFactor), 0, (((HdPos-Point).Unit):Cross(TrsoLV)).YHeadHorFactor), UpdateSpeed/2)
end
end
end
end
end
if TurnCharacterToMouse == true then
Hum.AutoRotate = false
Core.CFrame = Core.CFrame:lerp(CFrame.new(Core.Position, Vector3.new(Mouse.Hit.p.x, Core.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
else
Hum.AutoRotate = true
end
end
end)