I have a code that makes the camera a certain way, but I want a specific value (custom FieldOfView) to be able to change and still update.
Here is what I currently have, there are no errors or anything but it doesn’t change the value.
Script inside ProximityPrompt
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeFOV = ReplicatedStorage.Events:WaitForChild("changeFOV")
script.Parent.Triggered:Connect(function(player)
changeFOV:FireClient(player, 5)
end)
these two are to change the FOV while the game is running
LocalScript inside StarterGui
local FieldOfView = game.Players.LocalPlayer.PlayerScripts.FOV_Value
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeFOV = ReplicatedStorage.Events:WaitForChild("changeFOV")
changeFOV.OnClientEvent:Connect(function(zoom: number)
print(zoom)
FieldOfView.Value = zoom
end)
[IntValue]
This is the main camera script that handles how the camera acts (Its an isometric camera)
local script in StarterCharacterScripts
wait(.5)
local zoom = 140
local FieldOfView = game.Players.LocalPlayer.PlayerScripts.FOV_Value.Value
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
Camera.FieldOfView = FieldOfView
if Character then
if Character:FindFirstChild("Head") then
game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, Character.Head)
Camera.CFrame =
CFrame.new(Vector3.new(Character.Head.Position.X + zoom, Character.Head.Position.Y + zoom, Character.Head.Position.Z + zoom), Character.Head.Position)
end
end
end)