Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make it so this camera code allows me to swap infintely?

Asked by 4 years ago

Basically, im trying to make a camera system with multiplie cameras, but i can only switch to them once but i want to be able to switch to them as many times as i want, heres a video, https://streamable.com/uq7uks.

Here are the directories and the code of scripts:

Note: "CamButtons" is a frame

Camera 1 button directory: StarterGui\ScreenGui\CamButtons\Cam 1 Camera 1 local script StarterGui\ScreenGui\CamButtons\Cam 1\cam1script Camera 1 local script code:

local Enabled = false

script.Parent.MouseButton1Click:Connect(function()
    if not Enabled then
        Enabled = true
        game.Players.LocalPlayer.Backpack.Camera1.Disabled = false
        game.Players.LocalPlayer.Backpack.Camera2.Disabled = true
    end
end)

Camera 2 button directory: StarterGui\ScreenGui\CamButtons\Cam 2 Camera 2 local script StarterGui\ScreenGui\CamButtons\Cam 2\cam2script Camera 2 local script code:

local Enabled = false

script.Parent.MouseButton1Click:Connect(function()
    if not Enabled then
        Enabled = true
        game.Players.LocalPlayer.Backpack.Camera1.Disabled = true
        game.Players.LocalPlayer.Backpack.Camera2.Disabled = false
    end
end)

The open camera GUI / main button directory: StarterGui\ScreenGui\maincambutt The open camera GUI / main button local script: StarterGui\ScreenGui\maincambutt\camscript The open camera GUI / main button code:

local Enabled = false

script.Parent.MouseButton1Click:Connect(function()
    if not Enabled then
        Enabled = true
        game.Players.LocalPlayer.Backpack.Camera1.Disabled = false
        game.Players.LocalPlayer.PlayerGui.ScreenGui.CamButtons.Visible = true
    else
        Enabled = false
        game.Players.LocalPlayer.PlayerGui.ScreenGui.CamButtons.Visible = false
        workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
        game.Players.LocalPlayer.Backpack.Camera2.Disabled = true
        game.Players.LocalPlayer.Backpack.Camera1.Disabled = true
    end
end)

And finally, the "Camera1", "Camera2" local scripts. Both located in StarterPack

Camera 1 code:

while wait() do
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
    workspace.CurrentCamera.CFrame = workspace.CameraPart1.CFrame
end

Camera 2 code:

while wait() do
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
    workspace.CurrentCamera.CFrame = workspace.CameraPart2.CFrame
end

Again, im trying to make it so i can swap between the cameras as much as i want, but currently it only allows me to do it once for each camera. No errors or outputs.

0
I thinkkkk you forgot to set 'Enabled' to false in the first two when you switch to another camera. That's why the buttons wouldn't work afterwards. Afterl1ght 321 — 4y
1
oh wow, that is the answer Phantom_User101 17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I forgot to set Enabled to false in first 2 scripts

Ad

Answer this question