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)
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 )