Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The game doesn't recognise FOV, how do i make it work?

So basically I was trying to do random, but that didn't work so I decided to do something simple and just make it fixed, the only problem is that it won't work, even though it runs through it.

while true do
    game.Workspace.Camera.FieldOfView = 10
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 5
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 30
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 70
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 46
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 99
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 62
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 23
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 54
	wait(0.1)
	game.Workspace.Camera.FieldOfView = 92
	wait(0.1)
	print("hi")
	
end

2 answers

local camera = workspace.CurrentCamera
while true do
    camera.FieldOfView = 10
    wait(0.1)
    camera.FieldOfView = 5
    wait(0.1)
    camera.FieldOfView = 30 
    wait(0.1)
    camera.FieldOfView = 70
    wait(0.1)
    camera.FieldOfView = 46
    wait(0.1)
    camera.FieldOfView = 99
    wait(0.1)
    camera.FieldOfView = 62
    wait(0.1)
    camera.FieldOfView = 23
    wait(0.1)
    camera.FieldOfView = 54
    wait(0.1)
    camera.FieldOfView = 92
    wait(0.1)
    print("hi")

end

You have to address the camera is workspace as CurrentCamera, despite its name that you see. You can only access the camera with a local script too, so make sure to put a local script in ReplicatedFirst with the above code.

2 comments

0

It says current camera is not a valid member

0

I have edited the code. It should work now, but with the FOV changing so much it looks trippy lol

Use math.random(x,y) to create a random integer.

Use repeat wait(.01) until workspace.CurrentCamera to wait for the property.

Final result:

math.randomseed(tick())--Makes the math.random more “randomly”
repeat wait(.01) until workspace.CurrentCamera
local min = 1
local max = 100
while true do
    game.Workspace.CurrentCamera.FieldOfView = math.random(min,max)
    wait(.1)
end

I hope you get it.

More details: WikiArticle_Math,WikiArticle_Camera.

This discussion is preserved as it was. New answers, comments, and votes are closed.