Camera Script Not working

I have a script that makes the camera draggable, It works when I first start the game but… When I buy something from the shop and trying using the camera it dose not drag anymore.

https://medal.tv/games/roblox-studio/clips/zJUMEAjo6j7ON/d1337Zx0rJxc?invite=cr-MSxBa0wsMjQyMjcyMjcs

The video would not upload so here is a link of my problem

Would you mind attaching your code? Or any errors that could’ve occured in console.

local run = game:GetService’RunService’
local uis = game:GetService’UserInputService’

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local cam = workspace.Camera

local speed = 2
local lockMouse = true

local Zoom = Instance.new(“IntValue”)

Zoom.Value = 60

Zoom.Name = “Zoom”

local origin = CFrame.lookAt(Vector3.new(0,60,0), Vector3.new())
local moved = Vector2.zero

local dragging = false
local oldMousePos = Vector2.zero

cam.CameraType = Enum.CameraType.Scriptable

mouse.Button2Down:Connect(function()
dragging = true
oldMousePos = uis:GetMouseLocation()
end)
mouse.Button2Up:Connect(function()
dragging = false
uis.MouseBehavior = Enum.MouseBehavior.Default
end)

run.RenderStepped:Connect(function(dt)

if dragging then

if lockMouse then
		
uis.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
			
moved += uis:GetMouseDelta()*speed*dt

else

moved += (uis:GetMouseLocation() - oldMousePos)*speed*dt
		
oldMousePos = uis:GetMouseLocation()

end

end

cam.CFrame = origin * CFrame.new(-moved.X*speed, moved.Y*speed, 0)

end)

here is the code and their is not errors in the console

Well, First thing I would try is changing workspace.Camera to workspace.CurrentCamera :person_shrugging: