Help with this FOV tween

I’ve tired creating a FOV module to help customise the FOV during specific events however, I can’t manage to find out how to make it work. So far no errors have appeared but it doesn’t seem to work. Here is the code within the Module;

local Camera = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
easingtime = 0.035


local FOV = {}
function FOV.FOVChanger(FOV1,ChangeFOV,Time)
TweenService:Create(Camera,TweenInfo.new(Time,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0),{FieldOfView = ChangeFOV}):Play()
end
return FOV

and here is the code of the local script that is requiring and running it ;

local FOV = require(script:WaitForChild("Modules").FOVHandler)
FOV:FOVChanger(70,80,2)

I’m not quite sure what to do, could anyone help ?

Simple fix is replacing that colon with a dot. So, FOV.FOVChanger(70,80,2)

The reason this doesn’t work is because when you use a colon, you are passing the table itself as an argument so it could be used as the variable self. So the game actually sees the code like this, FOV.FOVChanger(FOV, 70, 80, 2) You can read more about this here: Methods.

Anyways, TLDR: Fix is simply FOV.FOVChanger(70,80,2) and not FOV:FOVChanger(70,80,2)

1 Like

Wow, coding can be shameful sometimes. Thank you a lot and thank you for explaining to me why it wouldn’t work.

1 Like

I got you homie! I try to explain as best as I can :wink:

1 Like