Fov in the thousands for no reason?

so I have this gui that lets you change your fov and your starting fov is 70 (woag.value is 70) and for some resaon when ingame it changes to like 3070
image

and when using a script to change the fov, this large number allows the script to work, but when i use the slider to change fov it just tweaks out and makes the screen very small. This hasn’t happened before, anyone know why?

local Mouse = game.Players.LocalPlayer:GetMouse()
local Slider = script.Parent
local Fill = script.Parent.e
local trig = script.Parent.TextButton
local woag = game.ReplicatedStorage.VALUES.woag
min = 70
max = 50

Fill.Size = UDim2.fromScale(woag.Value,1)
script.Parent.TextLabel.Text = tostring(math.round(woag.Value*max+min))

function UpdateSlider()
	local outpit = math.clamp((Mouse.X-Slider.AbsolutePosition.X)/Slider.AbsoluteSize.X,0,1)
	game.Workspace.Camera.FieldOfView = outpit*max+min
	
	script.Parent.TextLabel.Text = tostring(math.round(outpit*max+min))
	woag.Value = outpit
	Fill.Size = UDim2.fromScale(outpit, 1)
end

local slide = false

function Active()
	slide = true
	while slide do
		UpdateSlider()
		task.wait()
	end
end

trig.MouseButton1Down:Connect(Active)

game:GetService("UserInputService").InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		slide = false
	end
end)

The reason it is 3570 is because you multiplied woag.Value (70) with max (50) and add it with min (70). (70*50+70 = 3750) In UpdateSlider(), woag.Value becomes outpit each time updated which is a value between 0 and 1, even though you said it is the FOV. Nevertheless, your outpit*max+min equation shows that when the slider is at the left, the FOV is supposed to 70, but when the slider is at the right, the FOV is supposed to be 120. (I am not sure if you wanted the FOV to clamp between 70 and 50 OR 70 and 120.)

I assume you want the left end of the slider to represent 70 and the right side being 50 (since 70 is the minimum and 50 is maximum, apparently, and outpit returning 0 at the left and 1 at the right according to my test. I could be wrong.)

This can be achieved by the equation min+(max-min)*outpit which is 70 added on by (50-70) (-20) that is multiplied by outpit beforehand. This should result in the FOV that is 70 when slided to the left and 50 when slided to the right.

For example,

  • if the outpit is 0.5 (half of the slider) then it should result in 60. (halfway from 70 to 50)
  • if the outpit is 0.75 (75%) then it should result in 55. (because outpit is closer to 1, which is at the right, the value returned is closer to 50.)
  • if the outpit is 0.25 (25%) then it should result in 65. (because outpit is closer to 0, which is at the left, the value returned is closer to 70.)
  • if the outpit is 0 or 1 then it should result in 70 and 50 respectively.

If I am wrong, and you wanted the maximum and minimum number switched, you can swap the min and max value. Or If I am entirely wrong, please let me know.

I did a stupid and made 70+50 to be 120 because its 120 but I’ll take your feedback when I get home (maximum is 120)

1 Like