I keep getting a whole bunch of errors!

I found this script a while back and I wanted to fix and reuse it but I keep get errors and I have no clue on how to fix it I tried to find a fix here :: Humanoid.CameraOffset but no solutions! Any ideas on how to fix it?

error:: image

full script ::

updateBobbleEffect = function(…)
local datick = tick()
local hum = script.Parent:WaitForChild(“Humanoid”)
local magnitude = hum.MoveDirection.Magnitude
local xnum = 0
if xnum < magnitude then
hum = datick * 5
xnum = math.cos
magnitude = xnum(hum) * 0.35
hum.CameraOffset = hum.CameraOffset:lerp(Vector3.new(magnitude, math.abs(math.sin(datick * 5)) * 0.35, 0), 0.25)
end
local offsetA = hum.CameraOffset
local offsetB = offsetA * 0.75
hum.CameraOffset = offsetB
end

game:GetService(“RunService”).RenderStepped:Connect(updateBobbleEffect)

This line is causing the error, you first set hum to the Humanoid of the character, but then this line overwrites it, causing your error as a number does not contain a property called CameraOffset, you need to rename something so this wont cause any overwriting.

Perhaps try

updateBobbleEffect = function(…)
	local datick = tick()
	local hum = script.Parent:WaitForChild(“Humanoid”)
	local magnitude = hum.MoveDirection.Magnitude
	local xnum = 0
	if xnum < magnitude then
		local num = datick * 5
		xnum = math.cos
		magnitude = xnum(num) * 0.35
		hum.CameraOffset = hum.CameraOffset:lerp(Vector3.new(magnitude, math.abs(math.sin(datick * 5)) * 0.35, 0), 0.25)
	end
	local offsetA = hum.CameraOffset
	local offsetB = offsetA * 0.75
	hum.CameraOffset = offsetB
end
1 Like

Thank you! It didn’t work the first time but I did a tweak and it works just fine!

updateBobbleEffect = function(…)
local datick = tick()
local hum = script.Parent:WaitForChild(‘Humanoid’)
local magnitude = hum.MoveDirection.Magnitude
local xnum = 0
if xnum < magnitude then
local num = datick * 5
xnum = math.cos
magnitude = xnum(num) * 0.35
hum.CameraOffset = hum.CameraOffset:lerp(Vector3.new(magnitude, math.abs(math.sin(datick * 5)) * 0.35, 0), 0.25)
end
local offsetA = hum.CameraOffset
local offsetB = offsetA * 0.75
hum.CameraOffset = offsetB
end
game:GetService(‘RunService’).RenderStepped:Connect(updateBobbleEffect)

I’m glad I was able to help you! If you have anymore issues don’t be afraid to make another post!

1 Like

Yes yes will do! :+1: :+1: :+1: :+1: :+1:

1 Like