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

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

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

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!

1 comment

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

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