Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What would be better than Vector3 in this?

Asked by 8 years ago

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)
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) UserOnly20Characters 890 — 8y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

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

Answer this question