I’m pretty new to scripting and I’m making a tool where when equipped, it acts as a security camera and moves the camera to a C-frame of a part. The problem is, I placed it in StarterPack but whenever I test it, it doesn’t work when equipped, it only works when I drop the tool and pick it up again. How would I fix it?
Script:
local Tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character
local cam = game.Workspace.CurrentCamera
local Part = script.PartTrag.Value
function onEquippedLocal()
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
end
end
function onUneqippedLocal()
cam.CameraType = Enum.CameraType.Custom
cam.FieldOfView = 70
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUneqippedLocal)