Tweening camera offset

I am trying to make a screenshake for my game however whenever I tween the humanoids cameraoffset it errors with Unable to cast value to Object. However this does work on its own when I do CameraOffset = vector3 but I dont want it to be instant. I was wondering if there is something that I am unaware of or if there is an issue else where in my code.

	local function RanVector()
		return Vector3.new(Random.new():NextNumber(-Amount, Amount),0,Random.new():NextNumber(-Amount, Amount))
	end
			local vector = RanVector()
			local tween = game:GetService("TweenService"):Create(CameraClient, TweenInfo.new(0.5), {CameraOffset = vector})
			tween:Play()

image

Shouldnt the first argument in the tween create function be the humanoid?
local tween = game:GetService("TweenService"):Create(Humanoid, TweenInfo.new(0.5), {CameraOffset = vector})

Also if youre going to play a tween right after creating it, you can just do this instead:

tweenservice:Create(stuff here):Play()
1 Like

No, In this case Im using a custom scripted camera that factors in its own camera offset
Im essentially trying to do this…

local dic = {value=Vector3.new(0,0,0)};
game:GetService("TweenService"):Create(dic, TweenInfo.new(1), {value = Vector3.new(1,1,1)});

Well, from what i understand about tweens, the Unable to cast value to Object error means that the property does not exist, or cannot be tweened for whatever reason, or you named it incorrectly in the table.

Looks like you should be using a lerping function instead.

local function TweenVector(StartVector, EndVector, Duration)
	local Time = 0
	repeat
		Time += task.wait()
		local Vector = StartVector:Lerp(EndVector, Time / Duration)
		print(Vector)
	until Time > Duration
end

TweenVector(Vector3.new(0, 0, 0), Vector3.new(1, 1, 1), 1)

try doing it on the client aaaaaaaaaaaaaaaaaaaaaaaaaa