My camera script not working?

hey, im doing a script so when i equip a tool it creates a camera in front of the character, but idk why is this happening:

what it should happen for every part created is this:

image

You need to set the correct CFrame for the part

CameraCreator.Equipped:Connect(function()
   local campart = Instance.new('Part')
   campart.Name == 'Campart'
   campart.CanCollide = false
   campart.Transparency = 1
   campart.Parent = workspace
   campart.CFrame = CFrame.new(char.HumanoidRootPart.CFrame.LookVector * 3, Vector3.new(0,5,0))
end)

From your post I infer that you want to part to face up, so I’m making the part look up in the script above with CFrame.new()

well i cant try the script rn, but as i indicated in the image above, i want it to look directly at the player’s front, so what do i change for it to face the plrs front? thx!

Hmm I said up earlier since the front of the part was facing up… but nvm:

local cam = workspace.CurrentCamera
local posoffset = 0
CameraCreator.Equipped:Connect(function()
   local campart = Instance.new('Part')
   campart.Name == 'Campart'
   campart.CanCollide = false
   campart.Transparency = 1
   campart.Parent = workspace
   if char.Humanoid.MoveDirection ~= Vector3.new() then -- we need a different offset depending on whether player is moving or not
      posoffset = 5
   else
      posoffset = 3
   end
   campart.CFrame = CFrame.new(char.HumanoidRootPart.CFrame.LookVector * posoffset,char.HumanoidRootPart.Position)
   cam.CFrame = campart.CFrame
end)

This is obviously assuming that the camera part will not move, if it will then thats a different story

well i fixed the script a little bit and this is what happens:

also this is the script:

local tool = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local cam = workspace.CurrentCamera
local posoffset = 0
tool.Equipped:Connect(function()
	--cam.CameraType = Enum.CameraType.Scriptable
	local campart = Instance.new('Part')
	campart.Name = 'camPart'
	campart.CanCollide = false
	campart.Anchored = true
	campart.Transparency = 1
	campart.Parent = char
	if char.Humanoid.MoveDirection ~= Vector3.new() then -- we need a different offset depending on whether player is moving or not
		posoffset = 5
	else
		posoffset = 3
	end
	campart.CFrame = CFrame.new(char.HumanoidRootPart.CFrame.LookVector * posoffset,char.HumanoidRootPart.Position)
	cam.CFrame = campart.CFrame
end)

Ong I forgot, add the position of the hmr to the look vector