How do I make it so that my parts end will always face my torso?

The title already explains my problem so here’s the script:

local player = game.Players.LocalPlayer
local UIS = game:GetService(“UserInputService”)
local Char = player.Character or player.CharacterAdded:wait()
local Torso = Char:WaitForChild(“HumanoidRootPart”)
local var = false

UIS.InputBegan:Connect(function(input)

if input.KeyCode == Enum.KeyCode.R then
	
	while wait(.3)do
		
		print("Began")
		
		local tracer = Instance.new("Part")
		tracer.Parent = workspace.Baseplate
		tracer.Color = Color3.new(0.988235, 1, 0.184314)
		tracer.Anchored = true
		
		tracer.CFrame = ???

		tracer.Transparency = .5
		tracer.Name = "tracer"
	 	tracer.CanCollide = false
		

		if var == true then
			
			break
			
		end
	end
	
	var = false
	
	workspace.Baseplate:ClearAllChildren()
	
end

end)

UIS.InputEnded:Connect(function(input)

if input.KeyCode == Enum.KeyCode.R then
	
	var = true
	
end

end)

1 Like

You can calculate the CFrame by multiplying the torso’s cframe with an offset CFrame.

local offset = CFrame.new(0, 0, -3)

tracer.CFrame = Torso.CFrame*offset
1 Like

I mean something like this:

image

Using CFrame multiplication will make sure that it’s position and orientation relative to torso will always be the same.

Edit: Do you want to always keep it in the same position and only rotate it to face the torso?

If that’s what you want then you can do this.

tracer.CFrame = CFrame.lookAt(tracer.Position, Torso.Position)
1 Like

I can’t do it cause it will be nil

I just realised it’s actually lookAt, not LookAt. I changed the code.

1 Like

Not your fault ROBLOX is all over the place. I too would have assumed it’s LookAt.

2 Likes