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

What would be better than Vector3 in this?

So when its done, the part is on top of the brick above it. What could i do to stop that?

script.Parent.ClickDetector.MouseClick:connect(function()
	script.Parent.CFrame = CFrame.new(60.884, 17.1, -9.942)
	script.Parent.Rotation = Vector3.new(-180, -89.96, -180)
end)

1 comment

0

Why don't you get rid of line 2 and 3 and replace them with this: Workspace.Part.CFrame = CFrame.new(60.884, 17.1, -9.942,-0.0174523834, 1.52573587e-009, -0.99984771, 1.74832238e-007, 1, -1.52573587e-009, 0.99984771, -1.74832238e-007, -0.0174523834)

1 answer

✓ Accepted answer

A CFrame is both a position and an orientation.

You can make the rotation be a part of the CFrame using CFrame.Angles. CFrame.Angles(rx, ry, rz) produces a CFrame with the rotation rx, ry, rz (all in radians -- not degrees) at position 0.

You can make a rotated CFrame at a location in either of the two following ways:

CFrame.new(location) * CFrame.Angles(rx, ry, rz)
--
CFrame.Angles(rx, ry, rz) + location

where location is a Vector3.


In your code, it would look like this:

	script.Parent.CFrame = CFrame.Angles( math.rad(-180), math.rad(-89.96), math.rad(-180) )
		+ Vector3.new( 60.884, 17.1, -9.942 )

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