How to rotate an accessory that the user has equipped by script?

Until now, I never understood what I should rotate so that the accessory rotates by script. How do I do that?
Example of what an accessory is made up of:
image

3 Likes

Do you mean rotate to fit properly, or rotate to spin?

1 Like

Rotate only the accessory without the head also rotating

1 Like

you could try editing the weld properties of the accesory weld

1 Like

I had already thought about this, the problem is that I never managed to get it to work via script. how do I do?

i have no idea :skull:

i would try help but i dont have roblox studio on this computer so

1 Like

I’m going to put one of the attempts I made previously:

char:FindFirstChild(AccessoryName*).Handle.AccessoryWeld.C0 = CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))

Note: AccessoryName was obtained through a remote event that matches the name of the target accessory

so

char:FindFirstChild(AccessoryName*).Handle.AccessoryWeld.C0 = CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))

?
could be something to do with the “*” cause i’ve never heard of it being used in scripts

1 Like

“*” was just used as a note I wrote below. it doesn’t exist in the actual script.

oh

could you show errors that came out from the output?

1 Like

there are no errors, i will show the problem by video:
robloxapp-20230907-2304308.wmv (1.2 MB)
it ends up rotating the first time, the problem is that if I do it a second, third, etc., it doesn’t rotate anymore

try adding the math rad instead of setting it

1 Like

Can you give an example (sorry, I’m not thinking clearly as I practically had to code several lines all day long.)?

Well, I probably won’t get an answer from anyone else, I should be able to solve the problem tomorrow.

I recommend that if you are planning to create an accessory rotation system, to create a variable of the original accessory’s position so you can use it as an offset when rotating your accessory. Here’s a sample script:

local AccessoryWeld = game.Players.LocalPlayer.Character:FindFirstChild("Hat name here").Handle.AccessoryWeld --Change the "Hat name here" to your accessory's name.
local Old_C0 = AccessoryWeld.C0 --Our weld's original rotation and position.

AccessoryWeld.C0 = Old_C0 * CFrame.Angles(0, math.rad(180), 0) --We use our old hat's position to get the original offset and add a 180 degree to it using math.rad().

hatrotate

2 Likes

Sorry I’m only responding now. Thanks for the help, now I know how to rotate accessories

1 Like

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