CFrame Error, but shows no error/warnings

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make it show after you click join or spawn in button, it would fix the camera to your desired spawn location on the map/game.
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried none so far, because there’s no error or warnings shown within the script:

--[[
		 ______   _____ __________    ______   ______
	    / _/ _/  / ___// ____/ __ \_ / ____/  /  /  /
	   / // /    \__ \/ /   / /_/ (_) /_      / // / 
	  / // /    ___/ / /___/ ____/ / __/     / // /  
	 / // /    /____/\____/_/   (_)_/      _/ // /   
	/__/__/                               /__/__/     

	SECURE. CONTAIN. PROTECT 
	SPECIAL CONTAINMENT PROCEDURES.
	
	SCRIPTED BY: O5-8 'The Eclipse'
	
	SCRIPT FUNCTION: Handling player menu tools.
	 
--]]

local event = game.ReplicatedStorage:WaitForChild("MenuTools")
local GroupID = 4219056
local TestService = game:GetService("TestService")


local IntroEnabled = true -- if FALSE, it will enable the maintenence mode.

-- [[ ]] --

if IntroEnabled == false then
	TestService.ExecuteWithStudioRun = false
else
	TestService.ExecuteWithStudioRun = true
end

game.Players.PlayerAdded:connect(function(player)
	if IntroEnabled == true then
		local mainstuff = script.MAINGUI
		local clone = mainstuff:Clone()
		clone.Parent = player.PlayerGui
		clone:FindFirstChild("SCPF_MENU").Disabled = false
	end
	player.CharacterAdded:connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")
		local team = player.Team
		-- [[ ]] --
		if player:FindFirstChild("ShirtID") then
			for i, v in pairs(player.Character:GetChildren()) do
				if v:IsA("Shirt") or v:IsA("ShirtGraphic") then
					v:Destroy()
				end
			end
			local s = Instance.new("Shirt", player.Character)
			s.ShirtTemplate = "rbxassetid://" .. player:FindFirstChild("ShirtID").Value
		end
		if player:FindFirstChild("PantsID") then
			for i, v in pairs(player.Character:GetChildren()) do
				if v:IsA("Pants") or v:IsA("ShirtGraphic") then
					v:Destroy()
				end
			end
			local p = Instance.new("Pants", player.Character)
			p.PantsTemplate = "rbxassetid://" .. player:FindFirstChild("PantsID").Value
		end
		-- [[ ]] --
		if humanoid then
			-- [[ ]] --
			if humanoid then
				if IntroEnabled == true then
					if not player:FindFirstChild("Loaded") then
						humanoid.WalkSpeed = 0
						humanoid.JumpPower = 0
					end
				end
			end
			-- [[ ]] --
			local teamtools = team:GetChildren()
			print(#teamtools)
			local toolsup = 0
			if #teamtools > 0 then
				for i = 1, #teamtools do
					local tool = teamtools[i]:Clone()
					if tool and tool.Parent ~= player.Backpack then
						tool.Parent = player.Backpack
						toolsup = toolsup + 1
						if toolsup >= #teamtools then
							break
						end
					end
				end
			end
			if IntroEnabled == true then
				if player:FindFirstChild("CELL_NUM") then
					local cdcs = game.Workspace:WaitForChild("CDC_SPAWNS")
					delay(0.1, function()
						local cellname = player:FindFirstChild("CELL_NUM")
						if cellname then
							local cd = cdcs:FindFirstChild("CD" .. cellname.Value)
							local torso = player.Character:FindFirstChild("Torso")
							if torso then
								torso.CFrame = cd.CFrame + Vector3.new(0, 2, 0)
							end
						end
					end)
				end
			end
			-- [[ FUNCTION ]] --
			local function give_card(cardname)
				local cards = game:GetService("ServerStorage"):WaitForChild("CARD_CLEARANCE")
				local cardneeded = cards:FindFirstChild(cardname)
				if cardneeded then
					cardneeded:Clone().Parent = player.Backpack
				end
			end
			local startsentence = "[SCP] Card-"
			-- [[ CARD GIVING ]] --
			if player:GetRoleInGroup(GroupID) == "Level - 0"  then -- L0
				give_card(startsentence .. "L0")
			elseif player:GetRoleInGroup(GroupID) == "Level - 1"  then -- L1
				give_card(startsentence .. "L1")
			elseif player:GetRoleInGroup(GroupID) == "Level - 2" then -- L2
				give_card(startsentence .. "L2")
			elseif player:GetRoleInGroup(GroupID) == "Level - 3"  then -- L3
				give_card(startsentence .. "L3")
			elseif player:GetRoleInGroup(GroupID) == "Level - 4" then -- L4
				give_card(startsentence .. "L4")
			elseif player:GetRoleInGroup(GroupID) == "Level - 5" or player:GetRoleInGroup(GroupID) == "Site Director" then -- L5
				give_card(startsentence .. "L5")
			elseif player:GetRoleInGroup(GroupID) == "O5 Council" or player.UserId == 0 then -- Omni
				give_card(startsentence .. "Omni")
			elseif player:GetRoleInGroup(GroupID) == "O5-X" or player:GetRoleInGroup(GroupID) == "The Administrator" then -- Omni
				give_card(startsentence .. "Omega")
			else -- CD or CE
				if player:GetRoleInGroup(GroupID) == "Class - D" then
					give_card(startsentence .. "CD")
				elseif player:GetRoleInGroup(GroupID) == "Class - E" then
					--give_card(startsentence .. "CE")
				else
					give_card(startsentence .. "CD")
				end
			end
		end
	end)
end)

function OverheadGui(player, visible)
	local character = player.Character
	if player and character then
		local head = character:FindFirstChild("Head")
		local humanoid = character:FindFirstChild("Humanoid")
		if head:FindFirstChild("GiveGUI") then
			local ent = head:FindFirstChild("GiveGUI")
			for i, v in pairs(ent:GetChildren()) do
				v.Visible = visible
			end
		end
	end
end

local InUse = {}
local Entities = 0
local PlayersUse = {}


game.Players.PlayerRemoving:connect(function(player)
	local CPM = "SpawnRoom_" .. player.Name
	if not player:FindFirstChild("Loaded") then
		if workspace:FindFirstChild(CPM) then
			if workspace:FindFirstChild(CPM) then
				workspace:FindFirstChild(CPM):Destroy()
				if Entities > 0 then
					local removal = 0
					local table_pos = 0
					for i, v in pairs(PlayersUse) do
						if player.Name == v then
							table_pos = i
						end
					-- [[ ]] --
					table.remove(InUse, table_pos)
					table.remove(PlayersUse, table_pos)
					Entities = Entities - 1
					-- [[ ]] --
					local r = false
					for i = 1, #InUse do
						if Entities == InUse[i] then
							r = true
						else
							print("None Found")
						end
					end		
					if r == true then
						Entities = Entities - 1
					end	
					-- [[ ]] --
					end
				end
				print("We now have: " .. Entities)
				print("We have: " .. table.concat(InUse, ", ") )
				print("We have players: " .. table.concat(PlayersUse, ", ") )
			end
		end
	end
end)

event.OnServerEvent:connect(function(player, reason, ent)
	if reason == "Teleport" then
		local part = ent
		local torso = player.Character:FindFirstChild("Torso")
		if torso then
			torso.CFrame = part.CFrame + Vector3.new(0, 4, 0) -- this is where it is
		end
	elseif reason == "RemovePackages" then
		for i, v in pairs(player.Character:GetChildren()) do
			if v:IsA("CharacterMesh") then
				v:Destroy()
			end
		end
	elseif reason == "RemoveTP" then
		local CPM = "SpawnRoom_" .. player.Name
		if workspace:FindFirstChild(CPM) then
			if workspace:FindFirstChild(CPM) then
				workspace:FindFirstChild(CPM):Destroy()
				if Entities > 0 then
					local removal = 0
					local table_pos = 0
					for i, v in pairs(PlayersUse) do
						if player.Name == v then
							table_pos = i
						end
					-- [[ ]] --
					table.remove(InUse, table_pos)
					table.remove(PlayersUse, table_pos)
					Entities = Entities - 1
					-- [[ ]] --
					local r = false
					for i = 1, #InUse do
						if Entities == InUse[i] then
							r = true
						else
							print("None Found")
						end
					end		
					if r == true then
						Entities = Entities - 1
					end	
					-- [[ ]] --
					end
				end
				print("We now have: " .. Entities)
				print("We have: " .. table.concat(InUse, ", ") )
				print("We have players: " .. table.concat(PlayersUse, ", ") )
			end
	end
	elseif reason == "AddTP" then
		local object = game.ReplicatedStorage:WaitForChild("SpawnRoom"):Clone()
		local objectcam = object:FindFirstChild("CamPart")
		objectcam.Transparency = 1
		objectcam:FindFirstChild("Cam").Transparency = 1
		object.Name = ent
		object.Parent = game:GetService("Workspace")
		local objectspawn = object:FindFirstChild("PartSpawn")
		objectspawn.Transparency = 1
		local target = 0
		local t = 0
		-- [[ ]] --
		for i = 1, #InUse do
			if Entities == InUse[i] then
				target = Entities + 1
			else
				target = Entities
			end
		end
		-- [[ ]] --
		while t < target do
			for i, v in pairs(object:GetChildren()) do
				v.CFrame = v.CFrame + Vector3.new(-150, 0, 0)
			end
			t = t + 1
			wait()
		end
		wait(0.1)
		table.insert(InUse, Entities)
		table.insert(PlayersUse, player.Name)
		Entities = target + 1
		print("We now have: " .. Entities)
		print("We have: " .. table.concat(InUse, ", ") )
		print("We have players: " .. table.concat(PlayersUse, ", ") )			
	elseif reason == "Freeze" then
		local decide = ent
		if decide == true then
			local char = player.Character
			local humanoid = char:FindFirstChild("Humanoid")
			repeat wait() until humanoid
			humanoid.WalkSpeed = 0
			humanoid.JumpPower = 0
			OverheadGui(player, false)
		else
			local char = player.Character
			local humanoid = char:FindFirstChild("Humanoid")
			repeat wait() until humanoid
			humanoid.WalkSpeed = 16
			humanoid.JumpPower = 50
			OverheadGui(player, true)
		end
	elseif reason == "SetCamAngle" then
		local cameraPart = ent[1]
		local position = ent[2]
		repeat wait() until cameraPart
		cameraPart.CFrame = position
	elseif reason == "NoGUI" then
		local p = player.PlayerGui:FindFirstChild("MAINGUI")
		if p then
			p:Destroy()
		end
	elseif reason == "SetCharAngle" then
		local part = ent
		local char = player.Character
		local humanoid = char:FindFirstChild("Humanoid") 
		if part and part:IsA("Part") then
			if char and humanoid then
				local torso = char:FindFirstChild("Torso")
				local dir = torso.CFrame:pointToObjectSpace(part.Position)
				local spin_y =  math.atan2(dir.x, dir.z) + math.pi
				if torso then
					torso.CFrame = torso.CFrame * CFrame.Angles(0, spin_y, 0)
				end
			end
		end	
	elseif reason == "GiveGUI" then
		local mainstuff = script.MAINGUI
		local clone = mainstuff:Clone()
		clone.Parent = player.PlayerGui
		clone:FindFirstChild("SCPF_MENU").Disabled = false
	elseif reason == "SetTeam" then
		if ent then
		player.Team = ent
		else
		print("could not find team")
		end
	elseif reason == "ReplaceClothing" then
		local SS = ent[1]
		local SP = ent[2]
		print("FiredServer")
		if player then
			for i, v in pairs(player.Character:GetChildren()) do
				if v:IsA("Shirt") or v:IsA("Pants") or v:IsA("Clothing") or v:IsA("ShirtGraphic") then
					v:Destroy()
				end
			end
			local newS = Instance.new("Shirt", player.Character)
			newS.ShirtTemplate = "rbxassetid://" .. SS
			local newP = Instance.new("Pants", player.Character)
			newP.PantsTemplate = "rbxassetid://" .. SP
		end
	elseif reason == "Replace_hat" then
		local hat_model = ent
		if player then
		for i, item in pairs(player.Character:GetChildren()) do
			if item:IsA("Hat") or item:IsA("Accessory") then
				item:Destroy()
			end
		end
		local clone = hat_model:Clone()
		local character_humanoid = player.Character:FindFirstChild("Humanoid")
		character_humanoid:AddAccessory(clone)
		end
	elseif reason == "BodyColors" then
		local color = ent
		if player then
			for i, v in pairs(player.Character:GetChildren()) do
				if v:IsA("BodyColors") then
					local b_c = v
					b_c.HeadColor = color
					b_c.LeftArmColor = color
					b_c.RightArmColor = color
					b_c.LeftLegColor = color
					b_c.RightLegColor = color
					b_c.TorsoColor = color
				end
			end
		end
	elseif reason == "Change_Face" then
		local face_id = "rbxassetid:// " .. ent
		if player then
			if player.Character then
				local head = player.Character:FindFirstChild("Head")
				if head then
					head:FindFirstChild("face").Texture = face_id
				end
			end
		end
	elseif reason == "MakeAmbience" then
		local ambiencesound = script:WaitForChild("Ambience")
		local soundclone = ambiencesound:Clone()
		soundclone.Parent = player.PlayerGui
		soundclone:Play()
	elseif reason == "SetValues" then
		local tab = ent
		-- LAYOUT: {SHIRT_ID, PANTS_ID, FACE, SKIN CLR, HAIR}
		local val = Instance.new("BoolValue", player)
		val.Name = "Loaded"
		-- [[ ]] --
		if tab[1] then
			local val = Instance.new("IntValue", player)
			val.Name = "ShirtID"
			val.Value = tab[1]
			print("C1")
		end
		if tab[2] then
			local val = Instance.new("IntValue", player)
			val.Name = "PantsID"
			val.Value = tab[2]
			print("C2")
		end
		if tab[3] then
			local val = Instance.new("StringValue", player)
			val.Name = "FaceID"
			val.Value = tab[3]
			print("C3")
		end
		if tab[4] then
			local val = Instance.new("BrickColorValue", player)
			val.Name = "SkinColor"
			val.Value = tab[4]
			print("C4")
		end
		if tab[5] then
			local val = Instance.new("ObjectValue", player)
			val.Name = "Hat"
			val.Value = tab[5]
			print("C5")
		end
		if tab[6] then
			local val = Instance.new("BoolValue", player)
			val.Name = "RemovePackages"
			print("C6")
		end
	end
	end)
	
print(script.Name .. "_Loaded.")

Also, when you’re done selecting your character and all, it doesn’t pop up after you spawn in.

“Attempt to index nil with CFrame” means you are trying to set (or, potentially, get) the CFrameof something that does not exist (is nil). I believe you are trying to set the camera CFrame in this example, so this error would probably mean that your reference variable to the Camera object is nil.

Can you post the relevant line? That’s a lot of code to look through, but hopefully that lets you fix the problem.

event.OnServerEvent:connect(function(player, reason, ent)
	if reason == "Teleport" then
		local part = ent
		local torso = player.Character:FindFirstChild("Torso")
		if torso then
			torso.CFrame = part.CFrame + Vector3.new(0, 4, 0) -- this is where it is
		end
	elseif reason == "RemovePackages" then
		for i, v in pairs(player.Character:GetChildren()) do
			if v:IsA("CharacterMesh") then
				v:Destroy()
			end
		end
	elseif reason == "RemoveTP" then
		local CPM = "SpawnRoom_" .. player.Name
		if workspace:FindFirstChild(CPM) then
			if workspace:FindFirstChild(CPM) then
				workspace:FindFirstChild(CPM):Destroy()
				if Entities > 0 then
					local removal = 0
					local table_pos = 0
					for i, v in pairs(PlayersUse) do
						if player.Name == v then
							table_pos = i
						end
					-- [[ ]] --
					table.remove(InUse, table_pos)
					table.remove(PlayersUse, table_pos)
					Entities = Entities - 1
					-- [[ ]] --
					local r = false
					for i = 1, #InUse do
						if Entities == InUse[i] then
							r = true
						else
							print("None Found")
						end
					end		
					if r == true then
						Entities = Entities - 1
					end	
					-- [[ ]] --
					end
				end
				print("We now have: " .. Entities)
				print("We have: " .. table.concat(InUse, ", ") )
				print("We have players: " .. table.concat(PlayersUse, ", ") )
			end
	end

I don’t know which line is 209, but I think the problem might be torso.CFrame = part.CFrame, specifically the fact that part is nil. You should verify that ent exists before trying to use it.

This could be because the client didn’t pass a third argument (ent) or the ent part only exists on the client, and the server can’t see it.

In that case you’d be setting torso.CFrame to a Vector3 value. That’s not the issue here. CFrames | Documentation - Roblox Creator Hub

Yup, so add an if statement to check that ent (part) is not nil before you try to index it with CFrame on the server.

Can you write it out for me? I’m confused at this point, tried asking others for help as well.