How to make smooth FOV tween script?

I’m looking for a script that will make the player’s FOV slowly increase to a set number when a part is touched and I mean really slow. I’m making a horror game where the player enters a dark room that warps the FOV. I’ve tried normal zoom scripts but none work.

do this

(local script), (starterPlayerScripts or StarterCharacterScripts),

you can also use remoteEvents with this

local TweenService = game:GetService("TweenService")

local function ChangeFov(Fov, Time)
	TweenService:Create(workspace.Camera, TweenInfo.new(Time), {FieldOfView = Fov}):Play()
end
ChangeFov(90, 0.5) -- for testing
1 Like

And this will work when I touch a part?

yes.

Local Script inside starterPlayerScripts or StarterCharacterScripts:

local RemoteEvent = "Idk"
local TweenService = game:GetService("TweenService")

local function ChangeFov(Fov, Time)
	TweenService:Create(workspace.Camera, TweenInfo.new(Time), {FieldOfView = Fov}):Play()
end

RemoteEvent.OnClientEvent:Connect(ChangeFov)

Script inside the part:

local Part = script.Parent
local RemoteEvent = "Idk"

Part.Touched:Connect(function(dude)
	if dude.Parent:FindFirstChild("Humanoid") then
		RemoteEvent:FireClient(game.Players:FindFirstChild(dude.Parent.Name))
	end
end

it works:

(Ignore the borrowed account) hehe

1 Like

Does not work for me I’m getting some errors, also I dont see where to change how much I want the FOV to increase or decrease and the time it takes for the FOV to reach that number

Change the remote event variable

yes,

Change the first line to

local Part = script.Parent

and line 5 to

RemoteEvent:FireClient(game.Players:FindFirstChild(dude.Parent.Name))
local Part = script.Parent
local RemoteEvent = "Idk"

Part.Touched:Connect(function(dude)
	if dude.Parent:FindFirstChild("Humanoid") then
		RemoteEvent:FireClient(game:GetService("Players"):GetPlayerFromCharacter(dude.Parent))
	end
end

There is still an error, what is “dude”?

the player when it touches a part

Part.Touched:Connect(function(dude)
	print(dude.Parent.Name)
end)

I just want to call it dude sometimes

(dude.parent)) Expected ‘)’ (to close ‘(’ at line 4), got

create a folder on replicated storage, then create a remoteEvent on the folder, You can name the folder and remote event to anything

then change:

local RemoteEvent = "Idk"

on all of you scripts to:

local RemoteEvent = game.ReplicatedStorage.Folder.RemoteEvent

I put a local script in the part and pasted the first script, put the remote event named “FOVChanger” into ReplicatedStorage, and then put a script into serverscriptservice and pasted the second script, and nothing happens when i touch the part (walking on top)

First of all, is the part property named CanTouch set to true?

Yes it is set to true and anchored

It works fine on my end, you probably forgot to paste something.

d o . t h i s . s o . i t . w i l l . w o r k

Alright, I’ll have to delete brainfuls scripts and retry yours, one second.

dont change any names if you d