Issue Trying To Rotate An Accesory

Hello,
I am currently working on a script that rotates the player’s accessory by 90 degrees whenever they press a button. Everything works well, however, the accessory doesn’t rotate. I have tracked down the problem to the way I am rotating it, however, I am unsure how to get it to rotate properly. Here is my server script:


game.ReplicatedStorage.CustomizationEvents.ChangeWeld.OnServerEvent:Connect(function(player, AcessoryName, thingy, rot)
	print(player)
	print(AcessoryName)
	local children = player.Character:GetChildren()
	for i, child in ipairs(children) do
		if child:IsA("Accessory") then
			if child.Name == AcessoryName then
				local weld = child.Handle:FindFirstChildWhichIsA("Weld")
				if rot == 'x' then
					child.Handle.Rotation +=  Vector3.new(0, 90, 0) -- issue, doesn't rotate but unsure how to rotate it properly.
					print(child.Handle.Rotation)
				end
				
			end
		end
	end

end)

Any help would be appreciated!

1 Like

If you know the name of the Accessory, why do you need to check all children of Character to find it?

Check the value of Rotation before and after changing it. Angle rotation values behave strangely when set because they are restricted to certain unique values.

You should rotate from the attachment, and if that doesn’t work, rotate on both.

Also, use Orientation, not Rotation.

For optimization, you should also do if character:FindFirstChild(AccessoryName) then

Try this:

for _,Acc in pairs(player.Character:GetDescendants()) do
  if string.match(Acc.Name, "Handle") then
Acc.Orientation = Vector3.new(0,90,0)
  end
end

This Shouldn’t effect tools

I tried that above, and it appears to do nothing. I added print’s to check the orientation, and it says it is changing, but doesn’t actually appear to rotate on the character.