Hello! I made a bobbing system for my FPS Game, it works fine, until the player dies…
function bobView()
coroutine.wrap(function()
if humanoid.MoveDirection.Magnitude > 0 then
if humanoid.WalkSpeed == game.StarterPlayer.CharacterWalkSpeed then
boboffset = boboffset:Lerp(CFrame.new(math.cos(tick() * 1.2) * .01 ,-humanoid.CameraOffset.Y/10, 0) * CFrame.Angles(0, math.sin(tick()* -1) * -.01, math.cos(tick() * -1.2) *.02), .08)
elseif humanoid.WalkSpeed > game.StarterPlayer.CharacterWalkSpeed then
boboffset = boboffset:Lerp(CFrame.new(.7 ,-humanoid.CameraOffset.Y/6, -.5) * CFrame.Angles(-.3, .6, math.cos(tick() * -7) *.09), .05)
elseif humanoid.WalkSpeed < game.StarterPlayer.CharacterWalkSpeed then
boboffset = boboffset:Lerp(CFrame.new(math.cos(tick() * 1.5) * .05 ,-humanoid.CameraOffset.Y/10, 0) * CFrame.Angles(0, math.sin(tick()* -1.5) * -.005, math.cos(tick() * -1.5) *.015), .08)
elseif isAiming == true then
boboffset = boboffset:Lerp(CFrame.new(math.cos(tick() * .5) * .01 ,-humanoid.CameraOffset.Y/11, 0) * CFrame.Angles(0, math.sin(tick()* -.2) * -.01, math.cos(tick() * -.3) *.02), .08)
end
elseif humanoid.MoveDirection.Magnitude == 0 and isAiming == false then
boboffset = boboffset:Lerp(CFrame.new(math.cos(tick() *.1) * .01,-humanoid.CameraOffset.Y/3, math.cos(tick() *.3) * .05), .1)
elseif humanoid.MoveDirection.Magnitude == 0 and isAiming == true then
boboffset = boboffset:Lerp(CFrame.new(0,-humanoid.CameraOffset.Y/3, 0), .1)
end
end)()
end
As you can see from the video, the first bit is when the player spawned, the bobbing works and all, but the second bit, where the ForceField is visible, the bobbing just doesnt work anymore.
runService.RenderStepped:Connect(function(dt)
if viewmodel ~= nil and settings ~= nil then
-- there is stuff here but it's not related to the problem
end
bobView() -- not related to rest of script
end)
If somebody can help me I will appreciate it very much!