Object Rotation issue(via script)

Hello. I have made a hat giver that is supposed to give you a hat, but when I click it it gives me the hat but the hat is rotated weirdly.

Here is my script
On line 16 I tried to fix this by making the hats rotation the same as the players head.

If you know a way to fix this, please respond!

1 Like

try :

newhat.Main.Rotation = char.Head.Rotation + Vector3.new(0, -90, 0)


newhat.Main.Rotation = char.Head.Rotation + Vector3.new(0, 90, 0)

I think one of those should work fine,
let me know if it helped you!

I’m assuming you want to rotate the hat by 90 degrees? If so your adding a cframe with a vector3 which only offsets the x, y, and z values of the cframe, not the rotational values. If you wanted to rotate a cframe you would multiply it with a cframe with no translation (a cframe with a position of (0, 0, 0)).

newhat.Main.Rotation = char.Head.Rotation * CFrame.fromOrientation(0, math.rad(90), 0) -- offsets the characters head rotation by 90 degrees on the y axis 

oh yes you’r right ! I made a stupid mistake :sweat_smile:

BaseParts don’t have a Rotation property, use Orientation or CFrame instead. And what you should do is set the weld.C0 property to rotate the hat.

weld.C0 = CFrame.Angles(0,math.pi/2,0)
1 Like

I’ve tried this already. It doesnt work.

Doesn’t work properly. It technically rotates the hat correctly but now it stays facing the way it was and not at the front of the face…

Why are you not using accessories for this? Accessory fitting tool is way more convenient for this. You can find it in “Avatar” tab in studio.

I have 2 parts, can I still make it into an accessory?

If you weld one to the other then you can make it act like 1 part.

What position do I set C1 and C0 to be??

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.