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

What does the "CFrame.p" do in the code bits in the tutorial below?

Hi all!

Just found this tutorial on the official developer wiki and it mentions the "p" property of CFrame. Couldn't find a "p" property in the documentation of CFrame so asking for some quick help here.

From https://developer.roblox.com/en-us/articles/Making-a-ray-casting-laser-gun-in-Roblox:

Raycasting

Now that we’ve got our framework set up, let’s get started on casting a ray. Add this to your mouse down function:

local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - toolHandle.CFrame.p).unit * 300)

This will create a ray that starts at the center of the tool’s handle

(tool.Handle.CFrame.p)

and goes out 300 studs towards the mouse’s position

 ((mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)

1 comment

0

.p is pretty much CFrame but in Vector3 form, so for example, CFrame.new(1, 2, 3).p = Vector3.new(1, 2, 3). The reason you can't find it in the documentation is because (I believe) it's deprecated. Use CFrame.Position instead.

1 answer

It convert CFrame's position into vector3 data type position

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