Hello, I was trying to make a FOV saving script but apparently, it doesn’t work. I tried to search on the internet but couldn’t find anything. I appreciate any help.
This is the script:
local DataStoreService = game:GetService("DataStoreService")
local FieldOfViewDataStore = DataStoreService:GetDataStore("FieldOfViewDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local data
local success, errormessage = pcall(function()
data = FieldOfViewDataStore:GetAsync(plr.UserId.."-fov")
end)
if success then
game.Workspace.CurrentCamera.FieldOfView = data
else
print("Error while getting "..plr.Name.." FOV data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
FieldOfViewDataStore:SetAsync(player.UserId.."-fov",game.Workspace.CurrentCamera.FieldOfView)
end)
if success then
print("FOV saved for "..player.Name)
else
print("FOV data not found for "..player.Name)
warn(errormessage)
end
end)