Replace cframe.new with only rotation

script:

script.Parent.CFrame = CFrame.new(script.Parent.Position, torso.Position)

i am trying to turn this into cframe.angles or something else entirely, i need the cframe because i will be using body position and body gyro on it later, which will conflict with the cframe casuing it to teleport around and stuff, any ideas on how?

Use :ToEulerAnglesXYZ() to get the angles of your CFrame and CFrame.Angles to make a CFrame with rotation only. The answer is just a simple search away.

-- store your CFrame
-- then store the values from it's angles
-- then create a new CFrame from the angles with CFrame.Angles
local newCF = CFrame.new(script.Parent.Position, torso.Position)
local rx, ry, rz = newCF:ToEulerAnglesXYZ()
local rotationalCF = CFrame.Angles(rx, ry, rz)

script.Parent.CFrame = rotationalCF

yeah i tried something like that but it just teleported the part to somewhere 0,0,0, heres the full script if it helps:

function findTorso(pos)
	local closestDistance = math.huge
	local closestTorso = nil

	local tablePlayers = game:GetService("Players"):GetPlayers()

	for _, plr in pairs(tablePlayers) do
		if plr.Character then
			local Magnitude = (plr.Character.PrimaryPart.Position - pos).Magnitude

			if Magnitude < closestDistance then
				closestDistance = Magnitude
				closestTorso = plr.Character.Torso
			end
		end
	end

	return closestTorso
end

game:GetService("RunService").Stepped:Connect(function()
	local torso = findTorso(script.Parent.Position)
	if torso ~= nil then
		local newCF = CFrame.new(script.Parent.Position, torso.Position)
		local rx, ry, rz = newCF:ToEulerAnglesXYZ()
		local rotationalCF = CFrame.Angles(rx, ry, rz)

		script.Parent.CFrame = rotationalCF
	end
end)

That’s because you set no position.

huh, would i need position to make it rotate?

No, but, if you want it to have a position other than the default, 0, 0, 0 then you would need to change that.


this is what happens when i use

script.Parent.CFrame = CFrame.new(script.Parent.Position, torso.Position)

there is another force on it too

if not target:FindFirstChild("BodyPosition") then
			local bp = Instance.new("BodyPosition", target)
			bp.D = 300
			bp.MaxForce = Vector3.new(1000000, 1000000, 1000000)
		--	bp.P = 10000  -- Proportional value for more responsive movement
		end
		
		if not target:FindFirstChild("BodyGyro") then
			
			local bg = Instance.new("BodyGyro", target)
			bg.D = 200
			bg.MaxTorque = Vector3.new(1000000, 1000000, 1000000)
		end