Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make the player always face a brick?

So I scripted this whole bank robbery system for a group I'm in and for the last part I want an animation of like grabbing the money. I just need the torso to always face the brick with the clickdetector in it. I thought well CFrame might work but changing the torso's CFrame to the CFrame of the brick just isn't what I want. Like I need the torso to face the brick at any angle. If someone could help me get in the right direction for this I'd appreciate it a lot.

2 comments

0

CFrame.lookVector

0

Isn't lookVector where the torso is facing, How would I change that to be facing towards a brick?

1 answer

✓ Accepted answer

Not sure on exactly what kind of Rotation you are talking about.

But the following code does make the Local Player face the Part's position, even when it is rotated. However. this only works for Y Orientation. Not for the X or Z. If those are what you are looking for then, I guess you would have to do a bit of research. I, however, do not know if it is possible.

-- [Declaration Section]
--\\ Game Services   
local Player           = game:GetService("Players").LocalPlayer;
local Character        = Player.Character or Player.CharacterAdded:Wait();
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart");

--\\ Part Location
local Part             = workspace.Part;

-- [Output Section]
repeat wait()
	HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position, Part.Position);
until HumanoidRootPart.CFrame == CFrame.new(HumanoidRootPart.Position, Part.Position);

I don't really think I have to explain. So I haven't. Comment below if you do need me to.

This discussion is preserved as it was. New answers, comments, and votes are closed.