So i found this weird problem while scripting security cameras!
The camera flys to the CFrame
Camera.CameraType = Enum.CameraType.Scriptable
local Get_Camera = function()
for _, v in pairs(game.Workspace.Assets.Game_Resources.Cameras:GetChildren()) do
local CameraAmount = tostring(CurrentCamAmount)
if v.Name:match(CameraAmount) then
local Table = Resource.GameResources.Camera[v.Name]
Camera.CFrame = Table.Position
end
end
end
local SwitchCamera = function(Name, Action)
if Action == Enum.UserInputState.Begin then
if Name == "E" then
CurrentCamAmount = Clamp(CurrentCamAmount + 1, 0, 4)
Get_Camera()
elseif Name == "Q" then
CurrentCamAmount = Clamp(CurrentCamAmount - 1, 0, 4)
Get_Camera()
end
end
end
Context:BindAction("E", SwitchCamera, false , Enum.KeyCode.E)
Context:BindAction("Q", SwitchCamera, false , Enum.KeyCode.Q)