Hello. I’m new to scripting overall and decided to mess around with this service. I’ve come across a problem though, and I couldn’t find a solution for it… It’s a dumb mistake, I know, but I have no idea what to do rn
local camera = workspace.CurrentCamera
camera.FieldOfView = 60
local uis = game:GetService("UserInputService")
while task.wait(.5) do
if uis.IsKeyDown(Enum.KeyCode.F) then
camera.FieldOfView = 30 -- the idea is that while the F key is held, the FOV would reduce down to 30.
else
camera.FieldOfView = 60 -- if the F key isn't held, the FOV would be 60.
end
end
I don’t really use UserInputService but I’m pretty sure you can just change it to when the F key is press, change the FOV. And when the F key stops being pressed, change the FOV back.
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
-- change the player FOV
end
end)
uis.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
-- change the player FOV back
end
end)