Unable to cast to Dictionary Error

Hi there Other Developers,

I’ve been tweaking a bit with cameras and FOVs and I’m trying to make the FOV smoothly increase when the player sprints.

Here is my LocalScript:

--// SERVICES
local AllPlayers = game:GetService("Players")
local InputService = game:GetService("UserInputService")
local PlayerCamera = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")

--// VARAIBLES
local Player = AllPlayers.LocalPlayer
PlayerCamera.FieldOfView = 65

Player.CharacterAdded:Wait()
--// SPRINTING FUNCTIONS
local Humanoid: Humanoid = Player.Character.Humanoid
InputService.InputBegan:Connect(function(input, chatting)
	if chatting then return end
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Humanoid.WalkSpeed = 20
        -- Tween Service is bugging
         TweenService:Create(PlayerCamera, TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false), {PlayerCamera.FieldOfView, 80}):Play()
	end
end)

Thanks a lot!

The “goal” when creating a Tween just needs the name of the property and the desired end value within the table, which means that it should just need to be updated to the following for it to work properly:

{FieldOfView = 80}

Revised line of code

TweenService:Create(PlayerCamera, TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false), {FieldOfView = 80}):Play()
3 Likes

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