How do I correctly position a model in front of the camera without rotation?

I have spent a few hours now, thinking how to do this.
How do I place a model at the camera with the z position offset by 5, but rotation stays 0?

I know it has something to do with object space, but I don’t have the knowledge to know how to use it.
I’m also trying to learn a bit more about this, so please also explain your answers if possible!

(I know one rule is not to make people write whole systems for me, but i cant really find the answer i need on the internet.)

Could you give us more information what are you trying to achive? Then we even might be able to help!

I want the part you are going to place in a building system to show up like Minecraft for instance. I have most done, but I don’t like how the part/model’s rotation is the same as the camera rotation. So, I want the rotation to stay as 0,0,0 or any other chosen rotation.

also, i want the z-coordinate to be offset by like 6 studs so it isn’t straightly attached to the camera, but i think thats the root of the problem, because it just goes in the same direction no matter the cam orientation, as i think it moves in the world space

In first person? or third person

yeah, like an fps. I want it to show in front of the player’s pov

Okay Ill look if i even can make one.
But if u got the building system done u just could force the orientation to 0

by the way, the only thing I need is a CFrame as i have the rest of the building system done

Could you show me the system script?

sure, but it wont be the whole script as its two systems combined (I know, not that good but it is what it is)

function showItem(item)
	lastitem = currentitem
	currentitem = item.Name
	if game.ReplicatedStorage.Game.Items:FindFirstChild(itemdataModule[returneddata[tostring(game.Players.LocalPlayer.UserId)]["InventoryData"][selecteditem]["ItemID"]]) then
		if len(returneddata[tostring(game.Players.LocalPlayer.UserId)]["InventoryData"][selecteditem]) < 1 then
			if game.Workspace.CurrentCamera:FindFirstChild("ItemShown") then
				game.Workspace.CurrentCamera:FindFirstChild("ItemShown"):Destroy()
			end
		else
			if currentitem == lastitem then
				local cam = game.Workspace.CurrentCamera
				local model = cam:FindFirstChild("ItemShown")
				model:PivotTo(cam.CFrame)
			else
				local model = item:FindFirstChild("Model")
				if game.Workspace.CurrentCamera:FindFirstChild("ItemShown") then
					game.Workspace.CurrentCamera:FindFirstChild("ItemShown"):Destroy()
				end
				local newmodel = model:Clone()
				newmodel.Name = "ItemShown"
				newmodel.Parent = workspace.CurrentCamera
			end
		end
	end
end

lastitem currentitem are for detecting if the selected item is changed

I need to understand are you using Raycasting or :GetMouse()?

for what? could you explain what you mean?

I think you aren’t doing any of those just getting where the player looks.

im using the camera cframe to know where they look

Im trying to re create what you are trying to achieve so it will take a minute

1 Like

Maybe try this (haven’t tested)?

-- Get the camera
local cam = workspace.CurrentCamera
-- Get its position from the CFrame, and offset it by 2 on Z
local pos = cam.CFrame.Position * Vector3.new(0,0,2)
local model -- Your model
model:PivotTo(CFrame.new(pos))

Or, you could do something more hacky, like do :PivotTo() on a model with the camera’s original CFrame, then, do :PivotTo() on the unrotated model with the position of the rotated. that was a mouthful

1 Like
model.PrimaryPart.Position = Workspace.CurrentCamera.CFrame.Position
1 Like

Yea im out of luck, Goodluck tho!

1 Like

no, i want to move an model without using welds, and :PivotTo() seems to work the best so far