How to change the FOV?

hello i have a script that when u press f it makes ur screen zoom out, however when u press it. It goes to 70.9 then back to 70, Ive tried everything but it doesnt work! This is a local script but does anyone have any idea how to fix this? full script isnt in here but it does have ends and a wait() then debounce = false

local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
wait(0.1)
local tweeninfo = TweenInfo.new(0.5)
local cam = workspace.CurrentCamera

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F then
		if debounce == false then
			debounce = true
			TweenService:Create(cam, tweeninfo, {FieldOfView = 90}):Play()
			wait()
			debounce = false
		end
	end
	end)
1 Like

You didnt send the full script, so Im going to guess it has something to do with the debounce

just sent it can you try help me? cus ive been trying to solve it for weeks now

local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Field = 90

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F then
		TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.5), {FieldOfView = Field}):Play()
		Field = 90-Field+70
	end
end)

still doesnt work sadly. i use a lot of my scripts with FOV aswell so its annoying how none of them work as good as they could

havent found a fix, do u have any other solutions??

Perhaps there are some conflicts?


this is the properties

yes but it only goes up to 71.8 then goes back to 70

I don’t know why, since everything works for me, are you sure that there are no errors in the console, you placed the script where necessary, there are no other scripts that change the FOV

nope there definitely isnt and the script is in startercharacterscripts

And if you manually change the value, everything will be fine?

yes which is extremely weird but i just want to know how to fix it

oh no wait when i change it manually it works then when i test it goes back to 70

Try this script and show the console:

local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Field = 90

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F then
		print(Field)
		TweenService:Create(workspace.CurrentCamera, TweenInfo.new(0.5), {FieldOfView = Field}):Play()
		print(workspace.CurrentCamera.FieldOfView)
		Field = 90-Field+70
	end
end)

well thats weird but i just joined as my normal roblox avatar instead of a premade one and it works good ish now

very strange :confused: the main thing is that it works

nvm it doesnt i just changed it back to fieldofview and still doesnt work

Then paste the script that I threw and show the console

extremely weird but i just went into another game and used ur script now it works perfectly fine