Tween not working - "Unable to cast value to object"

I’m trying to tween the FOV of the player’s camera, however I am getting an error on the line that creates the tween.

Script:

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
local event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("SpellFOV")
-- default FOV = 70
-- spell FOV = 20

--SETUP TWEENS--

local fovGoal1 = {FieldOfView = 20}
local fovGoal2 = {FieldOfView = 70}
local fovInfo1 = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut)
local fovInfo2 = TweenInfo.new(.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut)
local fovTween1 = tweenService:Create(camera.FieldOfView, fovInfo1, fovGoal1)
local fovTween2 = tweenService:Create(camera.FieldOfView, fovInfo2, fovGoal2)

-------------------

event.OnClientEvent:Connect(function()
	fovTween1:Play()
	wait(.7)
	fovTween2:Play()
end)

Do not pass Camera.FieldOfView as the first argument to TweenService:Create(); simply pass Camera, as your table specifies which properties to modify.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.