ArcHandle to Rotate Accessory Weld C0. Please Help!

  1. What do you want to achieve?
    I am trying to make it so that I can use an ArcHandle to rotate a player’s accessory by getting the C0 of the weld inside said accessory and changing it’s Orientation value based on which axis I rotate and in which direction.

  2. What is the issue?
    I can’t seem to figure out how to ‘add’ to the Weld’s rotation instead of flat out replacing it. Line 8 shows how far I’ve gotten in my attempts to figure out a solution to this. I’m pretty confident I can fix this easily if I figure out how to get specific rotation axis out of PartToMove.C0 but I don’t know how to do that. Currently, ‘rotating’ the accessory rotates it once and then immediately ‘snaps’ it back to it’s default rotation angle. Code is below for reference

local PartToScale = nil
local movetool = script.Parent

	local origin = nil
	movetool.MouseDrag:Connect(function(a, b)
		if a.Value == 1 then
			print("1")
			PartToMove.C0 = origin * CFrame.Angles(0, math.rad(b), 0)
			PartToMove.Parent.SpecialMesh.Part.Orientation = Vector3.new(PartToMove.Parent.SpecialMesh.Part.Orientation.X, PartToMove.Parent.SpecialMesh.Part.Orientation.Y + b, PartToMove.Parent.SpecialMesh.Part.Orientation.Z)
		elseif a.Value == 0 then
			print("0")
		elseif a.Value == 2 then
			print("2")
		end
	end)
	
	movetool.MouseButton1Up:Connect(function()
		origin = PartToMove.C0
		game.ReplicatedStorage.UpdateHat:InvokeServer(PartToMove.Parent, PartToMove.Parent.SpecialMesh.Offset, PartToMove.Parent.SpecialMesh.Scale, origin)
	end)

game.ReplicatedStorage.accessorySelect.Event:Connect(function(x)
	PartToMove = x.Handle:FindFirstChildOfClass("Weld")
	origin = PartToMove.C0
end)
  1. What solutions have you tried so far?
    Honestly my brain hurts from looking at this code all day I’ve completely forgotten anything I’ve tried attempt or look up. My frustration is pretty much all a blur. My bad if this isn’t really useful info, but I am just so sick of looking at this script I can’t remember a second of myself working on it other than the parts where I’m slamming my head into a figurative brick wall.

I’d appreciate any help with this as I’ve been trying to debug this for hours and it’s driving me up the wall. I’d use more colourful language to express my frustrations here, but I’m presuming I can’t to be safe. Apologies if I am not thorough enough in explanation here, I’ll answer any questions if necessary, but my brain is drawing a blank on what I can add unprompted.

Thanks!

Hi, I’m not really following some elements of your script, but I made some minor changes and sort of got it working. I made comments in the script of my thoughts on the code and what I changed:

local PartToScale = nil
local movetool = script.Parent

local origin = nil
movetool.MouseDrag:Connect(function(a, b)
	if a.Value == 1 then
		print("1")
		--Variable b is already in radians; no need to do math.rad(b)
		--However, it's reversed, so I just made it negative for the direction to be correct
		PartToMove.C0 = origin * CFrame.Angles(0, -b, 0)
		
		--Unnecessary? Changing C0 moves the part, so I'm not sure why it would need to be rotated again?
		--PartToMove.Parent.SpecialMesh.Part.Orientation = Vector3.new(PartToMove.Parent.SpecialMesh.Part.Orientation.X, PartToMove.Parent.SpecialMesh.Part.Orientation.Y + b, PartToMove.Parent.SpecialMesh.Part.Orientation.Z)
	elseif a.Value == 0 then
		print("0")
	elseif a.Value == 2 then
		print("2")
	end
end)

movetool.MouseButton1Up:Connect(function()
	origin = PartToMove.C0
	--Commented out for testing
	--game.ReplicatedStorage.UpdateHat:InvokeServer(PartToMove.Parent, PartToMove.Parent.SpecialMesh.Offset, PartToMove.Parent.SpecialMesh.Scale, origin)
end)

game.ReplicatedStorage.accessorySelect.Event:Connect(function(x)
	PartToMove = x.Handle:FindFirstChildOfClass("Weld")
	origin = PartToMove.C0
	--Set adornee for testing
	movetool.Adornee = x.Handle
end)

I’m sure there’s more revising to be done, so feel free to ask for further help if required.
Good luck!

Second rotation is for the part the adornee is attached to, separate from the weld
Otherwise thanks, I’ll try this later

With minor adjustment, this works! Thanks, appreciate it!
devil-may-cry-dante

Apologies for so many replies, but if I try apply this same code to another axis to rotate that instead it causes weird oddities with rotation where how the accessory rotates doesn’t seem to update with its current rotation if that makes sense.

Game link to see what I’m talking about is below, my PC doesn’t have much storage space so recording is a bit hard, also it’s much easier to see what’s going wrong hands-on.

This is the current script :

local PartToScale = nil
local movetool = script.Parent

local origin = nil
movetool.MouseDrag:Connect(function(a, b)
	if a.Value == 1 then
		print("1")
		PartToMove.C0 = origin * CFrame.Angles(0, -b, 0)
	elseif a.Value == 0 then
		print("0")
		PartToMove.C0 = origin * CFrame.Angles(b, 0, 0)
	elseif a.Value == 2 then
		print("2")
		PartToMove.C0 = origin * CFrame.Angles(0, 0, b)
	end
end)

movetool.MouseButton1Up:Connect(function()
	origin = PartToMove.C0
	game.ReplicatedStorage.UpdateHat:InvokeServer(PartToMove.Parent, PartToMove.Parent.SpecialMesh.Offset, PartToMove.Parent.SpecialMesh.Scale, origin)
end)

game.ReplicatedStorage.accessorySelect.Event:Connect(function(x)
	PartToMove = x.Handle:FindFirstChildOfClass("Weld")
	origin = PartToMove.C0
end)

Any idea on how I might be able to fix these oddities? My current theory is that I need to, in PartToMove.C0 = origin * CFrame.Angles(0, -b, 0), replace the 0s with their respective angles in the PartToMove.C0 and then make it so -b adds to it’s angle. I think this might not work as intended, though.

I’d appreciate some assistance on this.
Thanks!

Nvm the issue was I needed to rotate the C1 instead of the C0. Lol.

Okay so issue
If the accessory moves (which it can, its a feature of my game) it’s rotating and moving rather than just rotating stationary
Any way I could fix that? I’ve been searching other forum posts but their solutions haven’t worked for me (Mainly looked here and tried implementing this How can I rotate an accessory with a script without moving the accessory? - #4 by dthecoolest but I can’t seem to get this working for me)

Thanks!

Hello again, I’m not sure how you’re going about moving the accessory, but I just moved the accessory using the C1 offset, and it seems to be working correctly.

This is the code I used:

local PartToScale = nil
local movetool = script.Parent

local origin = nil
movetool.MouseDrag:Connect(function(a, b)
	if a.Value == 1 then
		PartToMove.C1 = origin * CFrame.Angles(0, b, 0)
	elseif a.Value == 0 then
		PartToMove.C1 = origin * CFrame.Angles(b, 0, 0)
	elseif a.Value == 2 then
		PartToMove.C1 = origin * CFrame.Angles(0, 0, b)
	end
end)

movetool.MouseButton1Up:Connect(function()
	origin = PartToMove.C1
	--Commented out for testing
	--game.ReplicatedStorage.UpdateHat:InvokeServer(PartToMove.Parent, PartToMove.Parent.SpecialMesh.Offset, PartToMove.Parent.SpecialMesh.Scale, origin)
end)

game.ReplicatedStorage.accessorySelect.Event:Connect(function(x)
	PartToMove = x.Handle:FindFirstChildOfClass("Weld")
	--Apply a position offset
	PartToMove.C1 *= CFrame.new(5, 1, -3)
	origin = PartToMove.C1
	--Set adornee for testing
	movetool.Adornee = x.Handle
end)

Here’s before I rotated the accessory:

And after:

1 Like

Very nice stuff! Thanks!
Managed to figure it out myself and the code looks like this-

local PartToScale = nil
local movetool = script.Parent
local rx, ry, rz = nil
local orientation = nil

local origin = nil
movetool.MouseDrag:Connect(function(a, b)
	if a.Value == 1 then
		PartToMove.C1 = origin * CFrame.Angles(0, b, 0)
	elseif a.Value == 0 then
		PartToMove.C1 = origin * CFrame.Angles(b, 0, 0)
	elseif a.Value == 2 then
		PartToMove.C1 = origin * CFrame.Angles(0, 0, b)
	end
	local rx, ry, rz = PartToMove.C1.Rotation:ToOrientation()
	script.Parent.Parent.CustomisationGUI.AccessoryConfiguration.X.Text = math.floor((rx * 57.2957795131) * 1000)/1000
	script.Parent.Parent.CustomisationGUI.AccessoryConfiguration.Y.Text = math.floor((ry * 57.2957795131) * 1000)/1000
	script.Parent.Parent.CustomisationGUI.AccessoryConfiguration.Z.Text = math.floor((rz * 57.2957795131) * 1000)/1000
end)

movetool.MouseButton1Up:Connect(function()
	origin = PartToMove.C1
	game.ReplicatedStorage.UpdateHat:InvokeServer(PartToMove.Parent, origin, PartToMove.Parent.SpecialMesh.Scale, origin)
	game.ReplicatedStorage.rotToMove:Fire(origin)
end)

game.ReplicatedStorage.moveToRot.Event:Connect(function(x)
	origin = x
end)

game.ReplicatedStorage.accessorySelect.Event:Connect(function(x)
	PartToMove = x.Handle:FindFirstChildOfClass("Weld")
	origin = PartToMove.C1
end)

-With a few extra scripts to set it up like adding the C0 orientation to the C1 orientation and then setting the C0 orientation to 0, but if I ever do some kind of rewrite or the sorts I’ll definitely keep your solution in mind and try use it. Probably better than my disgusting mess code lol.

Thanks!