FOV Resetting Randomly

I have a script that tweens and sets the FOV, however once the tween finished it resets back to the default. I have a render stepped loop setting the FOV, and the print statement inside say the FOV is 45, but when I check it in the explorer, it is the default 60 again. I have no idea why this is happening.

Output:

Video of What’s Happening:

I need the fov to stay while holding right mouse

Is 45 the value of the FOV focus ?

Yup, the intended one. It says its set to it but in the explorer it says 60

1 Like

I tried to achieve what you wanted, and it does works:

local plr = game.Players.LocalPlayer

local char = plr.Character

local cam = workspace.CurrentCamera

local uis = game:GetService("UserInputService")

local ts = game:GetService("TweenService")

uis.InputBegan:Connect(function(input,gpe)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		ts:Create(cam,TweenInfo.new(.25),{FieldOfView = 45}):Play()
	end
end)

uis.InputEnded:Connect(function(input,gpe)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		ts:Create(cam,TweenInfo.new(.25),{FieldOfView = 70}):Play()
	end
end)

Video:

I think the issue in your code is that, using a RenderStep connection, the FieldOfView value is getting overrided right after the tween is being executed.
You don’t need to refresh the FOV value each frames.
Tell me if it’s not what you wanted to achieve.

1 Like

I appreciate the help, I’ll test the solution when I get home. I used the renderstepped thing to attempt to fix my issue in the beginning, so it wasn’t the cause. I’m working on someone else’s script so i’ll just re do what i have with yours. Thanks

1 Like

If you don’t mind me asking why does the game processed event matter?

1 Like

I used here the game processing event so the input isn’t firing when the player input state isn’t focusing on the game. I’m mostly pointing at when the player is using the chat, but yes, in the case of the mouse, it’s indeed kind of useless.

1 Like

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