[SOLVED] How to make the Current Camera's Field of View value as the value of a NumberValue?

Hey! I need some help here, so. I made a fov changing script with datastore to save the FOV the user set, the datastore and everything else works, but the script that actually changes the FOV. Please help, thanks!

Here is the script that makes the values…

Script Name: data

-- // Copyright 2022, UnspeakableGames112, All rights reserved.
game.Players.PlayerAdded:Connect(function(player)
	-- fov
	local fold = Instance.new("Folder")

	fold.Parent = player
	fold.Name = "Data"
	
	local fov = Instance.new("NumberValue")
	fov.Parent = fold
	fov.Name = "fov"
	
end)

image

Here is where they are located:

image

The script that sets the FOV of the camera:
Script Name: Localscript

-- // Copyright 2022, UnspeakableGames112, All rights reserved.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
	local data = player:WaitForChild("Data")
	local val = data:WaitForChild("fov")
		workspace.CurrentCamera.FieldOfView = val.Value
		print("value")
		end)
end)

image

You don’t need to listen for PlayerAdded or CharacterAdded on the client.

local player = game:GetService("Players").LocalPlayer

local data = player:WaitForChild("Data")
local val = data:WaitForChild("fov")

workspace.CurrentCamera.FieldOfView = val.Value
1 Like

Okay, I will change the script accordingly.

I’ve done it, and it works now, thank you!