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

How do I make a new instance have a certain rotation?

I want a script to spawn a new part (got that down) and give it the rotation of the body part it is spawned from. I've sorta got parts of it, so here is some of it:

fh.BrickColor = BrickColor.new("Bright yellow")
    fh.CFrame = CFrame.new(script.Parent.Parent.Character:FindFirstChild("Head").Position.X,script.Parent.Parent.Character:FindFirstChild("Head").Position.Y-0,script.Parent.Parent.Character:FindFirstChild("Head").Position.Z)--Edited
	fh.Rotation = Rotation.new(script.Parent.Parent.Character:FindFirstChild("Head").Rotation.X,script.Parent.Parent.Character:FindFirstChild("Head").Rotation.Y-0,script.Parent.Parent.Character:FindFirstChild("Head").Rotation.Z)
    game.Debris:AddItem(fh,0.8)

(P.S. There may be an indentation missing but that doesn't matter, I just need the parts rotation to be similar to that of the body part.)

2 answers

✓ Accepted answer

You can set the CFrame to the head's CFrame and it will give it the same position and rotation of the head object, for example:

fh.CFrame = script.Parent.Parent.Character:FindFirstChild("Head").CFrame

This will get the CFrame of the characters head, which contains the position and rotation of it, and set it to the part 'fh'

1 comment

0

The bearded man has done it again...

Well I don't quite understand what your code is doing.. but to match a new part's rotation with a predefined part's rotation then you just need to make the new part's CFrame equivelant to that of the predefined part.

local old = workspace.Part --Old part
local new = Instance.new('Part',workspace) --New part.

new.CFrame = old.CFrame --Match CFrames, equivelant rotation

In your case, you're wanting to match fh's CFrame with script.Parent.Parent.Character:FindFirstChild("Head")'s CFrame..

fh.CFrame = script.Parent.Parent.Character:FindFirstChild("Head").CFrame

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