(urgent help) How to switch handles local axis from object to world

The reason i’m asking this is because i’m trying to make it so when the player presses J it would switch the axis of handles on a object in the client as im working with handles to make a building system

i have absolutely no clue how to switch the axis of handles and there is no propreties inside of them that can be checked true or untrue

there is no answer online and i cant find anybody talking about it on the devforum, but one of my friends talked about :ToObjectSpace() and :ToWorldSpace() , but is that actually gonna help my case? and how do i even use them or how do they work? and if you know a better solution please let me know

part of the script im working on:

userInputService.InputBegan:Connect(function(input, istyping)
	if input.KeyCode == Enum.KeyCode.J and not istyping and not isTextBoxFocused() then
		if currentCopy and currentArrow and isInBuildingMode then
			useWorldAxis = not useWorldAxis
		end
	end
end)
if useWorldAxis then
	newCFrame = initialPartCFrame * CFrame.new(Vector3.fromNormalId(axis) * relativeAngle):ToWorldSpace()
			else
	newCFrame = initialPartCFrame * CFrame.new(Vector3.fromNormalId(axis) * relativeAngle):ToObjectSpace()
end

I want to note that when i did try that, and used it on the newly created CFrame, all it did was inversing the direction of the axis of where my handles would go, this is not really what i want, what i want is this:

when its on object axis
image

when its on world axis
image

and if you’re curious, this is how my handles look like (although thats not very important):

image
image

I’d really appreciate if you could help, thank you

The way I would approach this is, when using Object space, position the arrows around the part using its CFrame so that they’d be positioned relative to the part’s orientation.

On the contrary, when using World space, simply position the arrows around the part’s position with no consideration for its orientation. I don’t believe you would have to use :ToWorldSpace() for that unless there’s something I’m not considering, because you should just be able to offset by position alone.

1 Like

thank you for replying, the arrows (currentArrow) are handles and their adornee is the object itself so they are already positioned around the object

but i dont know how to use Object space or World space in the first place, and i cannot change the way the handles are positioned, so i assume i would have to mess with the object CFrame itself but i don’t know how to

Ah, I see. So, if that’s how you have it set up, couldn’t you make a small, invisible part centered to your selected part with no orientation? That way, instead of the arrows having the Adornee of your part and being locked to its orientation, you lock a small, invisible brick inside of it with no orientation and Adornee the arrows to that instead? Is that possible?

1 Like

While this could theoretically work, since I’m working on a building system, I cannot predict how big the object could be or if it’s even going to be a model or a BasePart. If the object is quite large, the part in the middle of it would be too small for the handles (arrows), and it wouldn’t provide an accurate display for the player.

Also, the reason im using handles is because they are great at making studio-like movements for ingame mechanics as they contain the propreties face and distance, which im actively using right now but i cannot share my entire script as it contains 900 lines of code

So it would be better if there was a way to automatically switch the local axis of the handles from object to world using the object CFrame, but i don’t know how to do that

I made a post about this a while ago:

World Space is relative to where th object is in the world, while Object space is where the object is relative to the part.
So a position in world space is the objects normal position on the map, while object space is based on where the other part is:

Position1 -- World Space | Based around the origin
(Position1 - Position2) -- Object Space | Based around Position1

You can think of it as the offset of from the main position, where as if you were to convert to World Space, you would get the position based around the origin again.


For this case, you dont seem to need it unless you are making an offset to a position of some kind, which could be used for something like an Attachment or Offsets (as already mentioned).

For the handles, you can either configure where the object is looking at by using the parts relative directions using properties such as LookVector, or by switching between Position and CFrame. Position to only mess with the position of the part is to the world as opposed to where its facing, or using CFrame, which can be used to manipulate the position by the objects orientation.

1 Like

Thank you for the reply, i can see now that :ToObjectSpace() and :ToWorldSpace() are not useful or needed for my case.

My idea was that when we press J, it would switch a variable called useWorldAxis from false to true, and that depending on whenever its true or false, it would change the behavior of the handles direction very similarely to how roblox studio reacts when we press CTRL + L
I’m basically just trying to replicate CTRL + L ingame

I don’t really understand how calculating the direction of the object using LookVector is gonna help my case, and i cannot use positions i have to stay on CFrame as it is how most of the rest of my script is operating for movements

				--rest of the script
	local newCFrame = initialPartCFrame * CFrame.new(Vector3.fromNormalId(axis) * relativeAngle)

					if TurnedOnGridSetting0 then
						if object:IsA("Model") then
							object:SetPrimaryPartCFrame(newCFrame)
						else
							object.CFrame = newCFrame
						end
					else
				--rest of the script

I don’t believe replicating CTRL + L ingame is impossible as ive seen 1 game doing it with their building system, but i don’t know how they did it

1 Like