FOV Script is only working in studio

Hello, I’m using an FOV script which I’ve slightly modified to rely on a remote event so a touched event can trigger it more easily.

The FOV script works perfect in studio, however when I’m testing in a live environment it just doesn’t work. It prints my print aswell, but the players FOV doesn’t change nor does their walkspeed.

Added a print to see if it would print it.
Set camera FOV to the == check before calling the == check.

Script:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
game.ReplicatedStorage.RemoteEvents.JumpscareFOV.OnClientEvent:Connect(function()
	local cam =	workspace.CurrentCamera
	cam.FieldOfView = 70
	print("Fov script called successfully!")
	wait()
	if cam.FieldOfView == 70 then
		local stopFOVamt = 90
		while task.wait() do
			cam.FieldOfView += 1
			if cam.FieldOfView >= stopFOVamt then
				cam.FieldOfView = 90
				hum.WalkSpeed = 7
				break
			end
		end
		wait(4)
		local stopFOVamt2 = 70
		while task.wait() do
			cam.FieldOfView -= 1
			if cam.FieldOfView <= stopFOVamt2 then
				cam.FieldOfView = 70
				hum.WalkSpeed = 16
				break
			end
		end
	else
		cam.FieldOfView = 70
		hum.WalkSpeed = 16
	end
end)

Thanks in advance!

1 Like

Still have no idea what’s causing my issue.


have the same issue.

I managed to fix the issue, but I don’t remember exactly how. I’ll look at the script to see if I can find the change I made and help you out!

This is the new version of the first script I posted which actually does it’s job properly.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local cam =	game.Workspace.CurrentCamera
game.ReplicatedStorage.RemoteEvents.JumpscareFOV.OnClientEvent:Connect(function()
	cam.FieldOfView = 70
		local stopFOVamt = 90
		while task.wait() do
			cam.FieldOfView += 1
			if cam.FieldOfView >= stopFOVamt then
				cam.FieldOfView = 90
				print("Fov raised to 90")
				hum.WalkSpeed = 7
				break
			end
		end
		wait(4)
		local stopFOVamt2 = 70
		while task.wait() do
			cam.FieldOfView -= 1
			if cam.FieldOfView <= stopFOVamt2 then
				cam.FieldOfView = 70
				print("Fov back to 70")
				hum.WalkSpeed = 16
				break
			end
		end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.