If you’re talking about spawning a part in front of the camera, you would just replace that script you had with the camera. What i’m guessing you want to do is this
local unit = (head.Position - camera.CFrame.p).Unit
part.CFrame = CFrame.new(head.Position, head.Position + unit*5)
This script gets the direction between the head and the camera, and directs a part 5 studs in the unit from the head.
I just tried it, and got some weird behavior because my game’s in Fortnite-esque third-person. I assume it’s because the camera’s position and the head are at an offset, so the part was spawning to the left of where it should be. If there was a way to do this sequence with CFrames:
Set the CFrame to the player’s head
Rotate the CFrame to be in line with the player’s camera rotation
local throwOffset = 5 --studs in front of head for part to spawn
local newPos = head.Position + camera.CFrame.lookVector*throwOffset
part.CFrame = CFrame.new(newPos,newPos+camera.CFrame.lookVector)