Problems with CFrame orientation

Hello, I am having this problem that is making me lose my marbles, the problem in question is I want the to make it so everytime the player presses a button it creates a part towards where the humanoidrootpart is looking at with an offset, that part is for apply the cframe to the camera directly althought the part is not needed later on its needed to see where the camera is looking.

        local ObjectSpace = HumanoidRootPart.CFrame:ToObjectSpace(HumanoidRootPart.CFrame)
		local Position = * 1) +,2,-2)) * CFrame.Angles(0, math.rad(-135),0)
		-- Debugging.
		local Part ="Part")
		Part.Parent = workspace
		Part.Size =
		Part.Anchored = true
		Part.CFrame = Position:ToWorldSpace(HumanoidRootPart.CFrame)
		Part.Name = "CameraPos"
		--Prevent player from moving.
		HumanoidRootPart.Anchored = true
		-- Changing camera mode, to lock it in place.
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = Position:ToWorldSpace(HumanoidRootPart.CFrame)

when player spawns and presses the button it creates the part, BUT if i move from the spawn POSITIONING GOES BALISTIC, causing this:


Part Position:

Camera Position:

HumanoidRootPart Goes ballistic:


not including camera because you can see that its not close to the character at all, I can’t wrap this around my head.

turns out the solution is

local Position = * 1) +,2,-2)) * CFrame.Angles(0, math.rad(-135),0)
local ObjectSpace = HumanoidRootPart.CFrame:ToWorldSpace(Position)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.