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

How do I make a brick face the same direction as the player?

LookVectors/cframes make no sense to me, so can someone help explain this to me?

2 answers

part.CFrame = CFrame.new(part.CFrame.p, targetCFrame.p)

You can construct a CFrame with two Vector3s. The first one is the position of the part and the second one is the position that you want the part to be facing.

So if you want the part to always be facing the player you would do it like this:

local RunService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local part = Instance.new("Part")
part.Parent = workspace

RunService.RenderStepped:Connect(function()
	part.CFrame = CFrame.new(part.Position, character.PrimaryPart.Position)
       -- or if you want the part to be facing the same direction the player is facing then you would do this: part.CFrame = CFrame.new(part.Position, part.Position + character.PrimaryPart.CFrame.LookVector)
end)

local Brick = workspace.Part

while true do
	wait()
	Part.CFrame = CFrame.new(Part.CFrame.p,Game:GetService("Players").devisings.Character.HumanoidRootPart.Position)
end

the first parameter should be the position you want the part, the second parameter is what you want the part to face. in this scenario the parts position will stay fixed, but will constantly be facing you.

2 comments

0

i know i could've used more variables for tidiness

0

-1 for bad code, events could have been used instead, and you don't answer the question in the body

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