Hi devs,
i’m currently working on a security camera system but my script gives a error. Can you guys pls give it a watch?
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local cam = workspace.CurrentCamera
local function alphabeticalOrder(instance)
local children = instance:GetChildren()
table.sort(children, function(c1, c2)
return c1.Name:Lower() < c2.Name:Lower()
end)
return children
end
local camParts = alphabeticalOrder(workspace.Camera)
local LArrow = script.Parent.LeftArrow
local RArrow = script.Parent.RightArrow
local arrowClickCooldown = false
char:WaitForChild("Humanoid").Seated:Connect(function(isSeated, seat)
if not isSeated or seat.Name ~= "CameraSeat" then
script.Parent.LeftArrow.Visible = false
script.Parent.RightArrow.Visible = false
cam.CameraType = Enum.CameraType.Custom
return
end
script.Parent.LeftArrow.Visible = true
script.Parent.RightArrow.Visible = true
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = camParts[1].CFrame
local camNumber = 1
RArrow.MouseButton1Click:Connect(function()
if arrowClickCooldown then
return
end
arrowClickCooldown = true
if camNumber == #camParts then
cam.CFrame = camParts[1].CFrame
camNumber = 1
else
cam.CFrame = camParts[camNumber + 1].CFrame
camNumber += 1
end
wait(0.1)
arrowClickCooldown = false
end)
LArrow.MouseButton1Click:Connect(function()
if arrowClickCooldown then
return
end
arrowClickCooldown = true
if camNumber == 1 then
cam.CFrame = camParts[#camParts].CFrame
camNumber = #camParts
else
cam.CFrame = camParts[camNumber - 1].CFrame
camNumber -= 1
end
wait(0.1)
arrowClickCooldown = false
end)
end)
i dont know whats wrong. Pls Help! Thanks for reading!