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

How does CFrame work and what are the functions?

The tutorials on the wiki are very bad and I don't understand any of it.

I know basic CFraming like how to rotate parts using CFrame.Angles I just want to learn more like CFrame.fromAxisAngle and how all those work and how to learn more about them. I really like CFraming and stuff like that but I don't know how to learn more. I see people using a ton of CFrame functions but I don't get how they learned it if the wiki shows bad tutorials on it and don't really go in-depth with it.

Can someone please explain briefly of what some of the CFrame functions do and how I could learn more about them?

2 comments

0

watch some youtube on cframe

0

You are right, roblox wiki is confusing as freak!

1 answer

I'd be happy to.

CFrame is a Roblox object that is used for many things, including teleportation and part movement (not Velocity). The function CFrame.new() is used to create a new CFrame object. Most of the time, CFrame is a Position (sometimes a Vector3) that is used for teleportation and such. In terms of teleportation, CFrame ensures that the Torso and its joints are teleported along with the Humanoid, like this:

x = math.random(1,255)
y = 1
z = math.random(1,255)
humanoid = script.Parent:FindFirstChild("Humanoid")
while true do
	wait(3)
	humanoid.Parent.Torso.CFrame = CFrame.new(Vector3.new(x,y,z))
	wait(1)
end

In terms of part movement, CFrame offers a sliding motion from point to point. Here's an example script of just that:

part = script.Parent
while true do
	for i = 1,20 do
		part.Position.CFrame = CFrame.new(part.Positon + Vector3.new(0,0,0.1))
	end
	for i = 1,20 do
		part.Position.CFrame = CFrame.new(part.Position - Vector3.new(0,0,0.1))
	end
	wait(0.1)
end

Unless you're interested in using Region3, that's all you need to know about CFrame.

2 comments

0

you realize the sliding motion script you sent wouldn't work since you didn't put any waits inside the for loop, it will just stay in the same position since it's moving instantly

0

right...my bad...just put the wait() function in there

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