I’m currently having this problem where my script does not work at all whatever I try. I’ve deleted code, Changed the parent of the script, I’ve checked if anything’s delaying the script. Nothing. The Button2Down doesn’t even run as well. No errors either.
If you guys can spot what’s going on in the script i’d appreciate it.
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Cam = script.Parent["UI"]["Camera UI"] --This variable gets the Cam Ui
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Connections = {}
local Camera = workspace.Camera
Mouse.Button2Down:Connect(function()
print("Clicked")
if Cam.Visible == true then
Cam.Visible = false
for _, Connection in pairs(Connections) do
Connection:Disconnect()
end
Camera.FieldOfView = 70
elseif Cam.Visible == false then
Cam.Visible = true
local fovTarget = 70
local EaseSpeed = .2
local scrollSpeed = 4
local RunService = game:GetService("RunService")
Connections["Changed"] = UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseWheel then
local up = input.Position.Z < 0 and 1 or -1
fovTarget += up * scrollSpeed
end
end)
Connections["Heartbeat"] = RunService.Heartbeat:Connect(function()
local fovCamera = Camera.FieldOfView
local fovDifference = fovTarget - fovCamera
Camera.FieldOfView += fovDifference * EaseSpeed
end)
end
end)