How do i use CFrame.LookAt with HumanoidRootPart on a normal script?

how can i make a part look at the players humanoidRootPart or can i use CFrame LookAt with the HumanoidRootPart on a normal Script?

sounds dumb but i just started to learn about CFrame and i really need to know this, i know how to find the RootPart with local scripts but not with normal scripts

You can do part.CFrame = CFrame.lookAt(part.Position, humanoidRootPart.Position)

1 Like

Its Probably best for you to learn about the very basics of CFrames (aka CoordinateFrames) before doing stuff like this as it can devolve into very confusing trigonometric concepts (Basically: Higher Level Math for Cool stuff), While yes, CFrame may look easy, I can ensure you, its not.

There are many Sources that will help you get a better understanding of what CFrame does for certain uses, As for example, I will show you a Basic use of CFrame, This is an Example of Applying an Offset based on a Parts Local Position:

Part.CFrame = CFrame.new(0,10,0) -- This will Apply an Entirely new CFrame
Part.CFrame = Part.CFrame * CFrame.new(0,10,0) -- This will Set an Offset to the CFrame

Things to Note:
CFrame.new() can imply a Position
CFrame.Angles()/CFrame.fromEulerAnglesXYZ() implys a Rotation

The Code may seem “Complicated” Depending on your understanding, but it is actually a very simple usage of CFrame.

However, As for Sources:
This should give you a Basic understanding of CFrames:


Anyway, to get on Topic, The Most Easiest way to get the Player is by placing a script with StarterCharacterScripts, this will make it so a Script will automatically be applied to the Character instead of you doing it manually, It will also give you easy access to the Player’s Character where all you have to do to get the Player is: script.Parent. And if you ever want to get Access to the Player Itself, you would use the function game.Players:GetPlayerFromCharacter(), its self Explanatory.

Another Simple way to get Access to The Player is Player.CharacterAdded, you first have to get the Player, and trust me, it isn’t as hard as it seems, you can use the Event game.Players.PlayerAdded to get the Player, this will detect a New Player who has joined the game while Player.CharacterAdded gets the Character who either Respawned, or just joined.

This is will walk you through the Process:

game.Players.PlayerAdded:Connect(function(player) -- This event will return a Player
    player.CharacterAdded:Connect(function(char) -- This event will return the Character
        -- code
    end) -- End of CharacterAdded Event
end) -- End of PlayerAdded Event

As you can see, not that Hard to Accomplish.

1 Like