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

How do I have the same rotation of one object as another?

Asked by 7 years ago
Edited 7 years ago

Hello scripters, I am trying to make a host have the same CFrame.Angles as UpperTorso but this script doesn't work.

uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(k)
    if k.KeyCode == Enum.KeyCode.E then
        char.HumanoidRootPart.Anchored = true
        local host = workspace.host
        host.Fire.Enabled = true
        host.CFrame = char.UpperTorso.CFrame * CFrame.Angles(char.UpperTorso.Rotation)

        for i = 1,10 do
            host.CFrame = host.CFrame + Vector3.new(0,0,-2)
            wait()
        end
        host.Fire.Enabled = false
        char.HumanoidRootPart.Anchored = false
    end
end)

1 answer

Log in to vote
0
Answered by 7 years ago

CFrame.Angles interprets stuff in radians with the operation of math.rad(x).

If you'd like to directly input the orientation of an object into CFrame.Angles, the only method I can think of is one that gets a liiiiitle messy. Here:

host.CFrame = char.UpperTorso.CFrame * CFrame.Angles(math.rad(char.UpperTorso.Orientation.X), math.rad(char.UpperTorso.Orientation.Y), math.rad(char.UpperTorso.Orientation.Z))

Hope this helped!

0
You could also use the inherited components of the CFrame and negate the position field. Such an example could yield: p2.CFrame = CFrame.new(p2.Position, select(4, p1.CFrame:components())) ScriptGuider 5640 — 7y
Ad

Answer this question