I’m pretty new at scripting and I can’t figure this out. I’m trying to make a debounce script that changes the Camera type and sets it to the c-frame of a part. It acts kind of like a security camera. It turns on, however, it won’t go back off. Any ideas why it’s not working?
Local Script:
local Tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character
local cam = game.Workspace.CurrentCamera
local Part = script.PartTrag.Value
debounce = false
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
if cam.CameraType == Enum.CameraType.Custom then
repeat wait()
cam.CameraType = Enum.CameraType.Scriptable
until cam.CameraType == Enum.CameraType.Scriptable
cam.CFrame = Part.CFrame
cam.FieldOfView = 40
script.Parent.BackgroundColor3 = Color3.new(0, 1, 0.498039)
print("ActivatedStage")
debounce = true
else
cam.CameraType = Enum.CameraType.Custom
cam.FieldOfView = 70
script.Parent.BackgroundColor3 = Color3.new(1, 0.701961, 0)
print("DectivatedStage")
debounce = false
end
end
end)