Issues with Bool Values and reading them

So before I explain the issue here is the code:

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()
	script.Parent.Parent.CameraMode = Enum.CameraMode.Classic
	script.Parent.Parent.CameraMinZoomDistance = 5
	game.ReplicatedStorage.camsOn = 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 == true then --Also, could be written as [[inputObject.KeyCode == "R"]]
     	--local vPlayer = game.Players.LocalPlayer
		--local character = vPlayer.Character
		game.ReplicatedStorage.camsOn = 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 == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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 script.camsOn == true and game.ReplicatedStorage.camsOn == 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)

(and yes the code is VERY messy)

And whats happening is that every time I play the game the output throws me this image

But it should be, I even have a yield for the instance but here is the replicated storage image

So there should be no reason why it keeps throwing me errors. Help?

you forgot to define “camsOn’s” Value make sure you do that, it is a common mistake made with values.

it should be:

game.ReplicatedStorage.camsOn.Value = true
1 Like

oh my gosh I make this mistake so often LOL

1 Like