local player = game.Players.LocalPlayer.UserId
local characterName = game.Players:GetNameFromUserIdAsync(player)
local char = game.Workspace:WaitForChild(characterName)
local hum = char:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local current = script.current.Value
camera.CameraType = Enum.CameraType.Fixed
local UserInputService = game:GetService("UserInputService")
local actionKey = Enum.KeyCode
function playCam()
game.Workspace.sounds.CamsChange:Play()
end
camera.CameraSubject = hum
local camsGui = script.Parent.Parent.PlayerGui.ScreenGui.Cams
game.ReplicatedStorage:WaitForChild("camsOn")
camera.CameraSubject = hum
game.Workspace.computer.Part.ClickDetector.MouseClick:Connect(function()
game.ReplicatedStorage.camsChanged:Fire("showstage")
script.Parent.Parent.CameraMode = Enum.CameraMode.Classic
script.Parent.Parent.CameraMinZoomDistance = 5
game.ReplicatedStorage.camsOn.Value = true
if current == "parts" then
camera.CameraSubject = game.Workspace.partsandservice
elseif current == "vent1" then
camera.CameraSubject = game.Workspace.VentCam1
elseif current == "vent2" then
camera.CameraSubject = game.Workspace.VentCam2
elseif current == "vent3" then
camera.CameraSubject = game.Workspace.VentCam3
elseif current == "vent4" then
camera.CameraSubject = game.Workspace.VentCam4
elseif current == "showstage" then
camera.CameraSubject = game.Workspace.showstage
end
--game.StarterGui.ScreenGui.CameraGUI.Visible = true
game.Lighting.FogEnd = 300
game.Workspace.sounds.CamsChange:Play()
camera.FieldOfView = 90
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.S and game.ReplicatedStorage.camsOn.Value == true then --Also, could be written as [[inputObject.KeyCode == "R"]]
--local vPlayer = game.Players.LocalPlayer
--local character = vPlayer.Character
script.current.Value = "showstage"
game.ReplicatedStorage.camsChanged:Fire("none")
game.ReplicatedStorage.camsOn.Value = false
script.Parent.Parent.CameraMode = Enum.CameraMode.LockFirstPerson
script.Parent.Parent.CameraMinZoomDistance = 0.5
--local humanoid = character:FindFirtChild('Humanoid') -- This should detect the humanoid of the player
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Follow
playCam()
game.Lighting.FogEnd = 50
--game.StarterGui.ScreenGui.CameraGUI.Visible = false
--game.StarterGui.ScreenGui.Cameras.Visible = false
game.Workspace.CurrentCamera.CameraSubject = hum
game.Workspace.CurrentCamera.FieldOfView = 70
end
end)
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E and script.current.Value == "parts" and game.ReplicatedStorage.camsOn.Value == true then --Also, could be written as [[inputObject.KeyCode == "R"]]
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam1
script.current.Value = "vent1"
game.ReplicatedStorage.camsChanged:Fire("vent1")
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.E and script.current.Value == "vent1"and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam2
game.ReplicatedStorage.camsChanged:Fire("vent2")
script.current.Value = "vent2"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.E and script.current.Value == "vent2" and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam3
game.ReplicatedStorage.camsChanged:Fire("vent3")
script.current.Value = "vent3"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.E and script.current.Value == "vent3" and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam4
game.ReplicatedStorage.camsChanged:Fire("vent4")
script.current.Value = "vent4"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.E and script.current.Value == "vent4" and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam5
game.ReplicatedStorage.camsChanged:Fire("vent5")
script.current.Value = "vent5"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.E and script.current.Value == "vent5"and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.showstage
game.ReplicatedStorage.camsChanged:Fire("showstage")
script.current.Value = "showstage"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.Q and script.current.Value == "showstage"and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam5
game.ReplicatedStorage.camsChanged:Fire("vent5")
script.current.Value = "vent5"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.Q and script.current.Value == "vent5" and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam4
game.ReplicatedStorage.camsChanged:Fire("vent4")
script.current.Value = "vent4"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.Q and script.current.Value == "vent1" and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.partsandservice
game.ReplicatedStorage.camsChanged:Fire("parts")
script.current.Value = "parts"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.Q and script.current.Value == "vent4" and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam3
game.ReplicatedStorage.camsChanged:Fire("vent3")
script.current.Value = "vent3"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.Q and script.current.Value == "vent3"and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam2
game.ReplicatedStorage.camsChanged:Fire("vent2")
script.current.Value = "vent2"
playCam()
elseif inputObject.KeyCode == Enum.KeyCode.Q and script.current.Value == "vent2"and game.ReplicatedStorage.camsOn.Value == true then
game.Workspace.CurrentCamera.CameraSubject = game.Workspace.VentCam1
game.ReplicatedStorage.camsChanged:Fire("vent1")
script.current.Value = "vent1"
playCam()
end
end)
--game.StarterGui.ScreenGui.Cameras.Visible = true
end)
So after you read through my absolute hodge-podge of code here, let me explain the problem. When you first play the game, you are able to go through every single camera just fine. Once you press S and click the cameras again, thats when things get to be wierd. The 2nd time you view the cameras, you cant flip to the 1st, 3rd, and 5th cameras respectively. The 3rd time you view the cameras, you can only view 3 of the cameras. This has had me very confused for a while, so any help would be great.