So I am working on a artillery script for a mortar I have and basically I have it set up to where Instead of having a script in each one I have 1 script that controls them all in an unlaggy ability. Now here is my script so far I just started on it today and I am trying to get the camera to work right which it does just on only 1 mortar seat.
player = game.Players.LocalPlayer;
mouse = player:GetMouse();
MapCam = game.Workspace.CameraPart;
mortars = {};
for index, child in ipairs(workspace:GetChildren()) do
if child.Name == "Mortar" then
local m_index = #mortars + 1;
mortars[m_index] = child;
end
end
for index, mortar in ipairs(mortars) do
mortar.Name = "Mortar" .. index;
end
while true do
wait(0.1);
for index, mortar in ipairs(mortars) do
local found = mortar.Artillery.Seat:FindFirstChild("SeatWeld");
if found then
if mortar.Artillery.Seat.SeatWeld.Part1.Parent.Name == player.Name then
CurrentCam = game.Workspace.CurrentCamera;
CurrentCam.CameraType = "Watch";
CurrentCam.Focus = CFrame.new(0, 0, 0);
CurrentCam.CoordinateFrame = CFrame.new(MapCam.Position);
CurrentCam.CameraSubject = MapCam;
end
else
CurrentCam = game.Workspace.CurrentCamera;
CurrentCam.CameraSubject = player.Character.Humanoid;
CurrentCam.CameraType = "Custom";
end
end
end
Could anyone explain to me what the problem is and a potential solution? Thanks in advance.

2 comments
Is this in a Local Script?
Yes it is.