FOV script not working

Let’s get straight into it, so I’ve been trying to make an FOV system recently but nothing has been working.

This is my script:

workspace.Camera.CameraType = Enum.CameraType.Scriptable
workspace.Camera.FieldOfView = script.Parent.Text

By the way the Gui is a textbox.

I’ve also tried doing it with a button:

workspace.Camera.CameraType = Enum.CameraType.Scriptable

script.Parent.MouseButton1Click:Connect(function()

workspace.Camera.FieldOfView = 60

end)

But that also didn’t work. If you have any ideas please tell me!

1 Like

you need to use workspace.CurrentCamera
not workspace.Camera
this is the problem

I’ve just tried that but it isn’t changing anything. Here’s the script:

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.FieldOfView = script.Parent.Text

Give this a try and let me know if it works.
(You don’t need to change the CameraType to set the FieldOfView.)

workspace.CurrentCamera.FieldOfView = tonumber(script.Parent.Text)

It still doesn’t work. It prints 70 and I see no changes to my camera. By the way I’ve added an extra line for checking what FOV the camera is on. This is the line:

print(workspace.CurrentCamera.FieldOfView)

Could you possibly show me your full script and a screenshot of where the TextBox and script is?

I’ve mentioned the full script in my post.

The text box is here:

image
The script is here:
image

Is the script named “Detect” the one setting the FieldOfView?

Yes it’s setting the field of view

Put the code of it in a local script.

You should try this instead;

workspace.Camera.CameraType = Enum.CameraType.Scriptable

button.MouseButton1Click:Connect(function()
    workspace.Camera.FieldOfView = tonumber(TextBox.Text)
end)

I put it in a local script but it didn’t work.

Are there any errors in the output?

Nope, there are no errors regarding the script.

This also didn’t work unfortunately.

Put this in your script that is parented to the TextBox.

script.Parent.Changed:Connect(function()
    workspace.CurrentCamera.FieldOfView = tonumber(script.Parent.Text)
end)

And make sure it is in a LocalScript.

1 Like

Yea I assume this one should work just fine.