He's some example code that I'm working on. However, please don't only pay attention to the code. If you have your own idea, please share it.
-- Either put this in a seat, if it can only be used in a seat, or do your own thing with it.
function waitForChild(parent, childName)
while true do
local child = parent:findFirstChild(childName)
if child then
return child
end
parent.ChildAdded:wait()
end
end
-- If you find any problems with this script, please message me (Daviidi), and I will try to fix them. :-)
local camdb
local mycamera
local hint = Instance.new("Hint")
local selid = 0
local selected = false
local inuse = false
local currentcam = 1
local newcamera = Instance.new("Camera")
local keycon
showhintid = 0
function ResetCamera()
if not mycamera then
return
end
mycamera.Parent = workspace
workspace.CurrentCamera = mycamera
mycamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
mycamera.CameraType = "Custom"
end
function displayhints(cursel)
hint.Parent = game.Players.LocalPlayer
local chid = showhintid + 1
showhintid = chid
hint.Text = "Security Cameras ON"
wait(4)
if (showhintid ~= chid) then
hint.Text = "Press Q to start viewing security cameras"
wait(5)
end
if (not selected) or (selid ~= cursel) or (showhintid ~= chid) then
hint.Parent = nil
end
end
function SelectCamera(ID)
currentcam = ID
if not camdb then
return
end
local thiscam = camdb:GetChildren()[ID]
if not thiscam then
return
end
local chid = showhintid + 1
showhintid = chid
AttachCamera(thiscam)
hint.Text = "Now Viewing: ".. thiscam.Name.. ", Press Q and E to switch"
hint.Parent = game.Players.LocalPlayer
end
function AttachCamera(securitycam)
if not mycamera then
return
end
newcamera.CameraType = 1
newcamera.Focus = securitycam.CFrame * CFrame.new(Vector3.new(0,0,-0.35001))
newcamera.CoordinateFrame = securitycam.CFrame * CFrame.new(0,0,-0.35)
newcamera.Parent = workspace
workspace.CurrentCamera = newcamera
end
function KeyPress(key)
if (not inuse) or (not camdb) then
return
end
if (#camdb:GetChildren() < 1) then
return
end
key = string.upper(key)
if key == "Q" then
if currentcam == 1 then
currentcam = #camdb:GetChildren()
else
currentcam = currentcam - 1
end
elseif key == "E" then
if currentcam == #camdb:GetChildren() then
currentcam = 1
else
currentcam = currentcam + 1
end
else
return
end
SelectCamera(currentcam)
end
script.Parent.Selected:connect(function(mouse)
mycamera = workspace.CurrentCamera
selected = true
local cursel = selid + 1
selid = cursel
if not inuse then
if camdb then
if #camdb:GetChildren() > 0 then
inuse = true
keycon = mouse.KeyDown:connect(KeyPress)
SelectCamera(currentcam)
else
local chid = showhintid + 1
showhintid = chid
hint.Text = "Could not find any security cameras"
hint.Parent = game.Players.LocalPlayer
wait(4)
if (showhintid == chid) then
hint.Parent = nil
end
end
else
local chid = showhintid + 1
showhintid = chid
hint.Text = "Could not find any security cameras"
hint.Parent = game.Players.LocalPlayer
wait(4)
if (showhintid == chid) then
hint.Parent = nil
end
end
end
end)
script.Parent.Deselected:connect(function()
inuse = false
selected = false
showhintid = showhintid + 1
hint.Parent = nil
if keycon then
keycon:disconnect()
keycon = nil
end
ResetCamera()
end)
if script.Parent.MustBeInSeat.Value then
coroutine.resume(coroutine.create(function()
while true do
if not game.Players.LocalPlayer.Character.Humanoid.Sit then
break
end
wait()
end
inuse = false
selected = false
showhintid = showhintid + 1
hint.Parent = nil
if keycon then
keycon:disconnect()
keycon = nil
end
ResetCamera()
script.Parent:Remove()
end))
end
camdb = waitForChild(workspace, script.Parent.CameraGroup.Value)

3 comments
i would recommend just changing the camera position
OK, any suggestions/help how to do it?
Just message Daviidi :)