Hello! I’ve been trying to make a script that changes the FOV of the localplayer when a specific part is touched, but I have no idea how to make this work. I’ve looked up videos and searched the devforum for an answer, but could not find any specific articles… Can anybody help me?
workspace.Part.Touched:Connect(function(hit) -- Switch the part with the part of your choice. Checks if the part was touched. if game.Players:GetPlayerFromCharacter(hit.Parent) then -- Checks if the thing that touched the part is a player. workspace.CurrentCamera.FieldOfView = Number -- Any number of your choice, Sets the players fov to the number. end end)
I don’t actually know where fov is but what you can do is
local part = [part] part.Touched:Connect(function(hit)) if hit.Parent:FindFirstChild('Humanoid') then workspace.CurrentCamera.FieldOfView end end)
Oh my gosh. I overcomplicated it. Thank you sm!
No problem! Glad to help you with your problem.
You should check if the touching player is equal to the local player the script is executing for (otherwise the FOV change will occur for everyone).
local Game = game local Players = Game:GetService("Players") local LocalPlayer = Players.LocalPlayer local Workspace = workspace local Camera = Workspace.CurrentCamera local Baseplate = Workspace:WaitForChild("Baseplate") --Change this. local function OnTouched(Part) local Model = Part:FindFirstAncestorOfClass("Model") if not Model then return end local Player = Players:GetPlayerFromCharacter(Model) if Player ~= LocalPlayer then return end Camera.FieldOfView = 120 --Change this. end Baseplate.Touched:Connect(OnTouched)
Test the script you provided with multiple players in a test server. The FOV change will occur for each player when just one player touches the part.
Oh your right, sorry. I tested it before and I set the fieldofview before to normal.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.