A rotating player tool part won't stay attached properly to tool while rotating

Hi, I have a weird issue. I made this tool that’s like a thin cylinder that the player holds (handle), and on top of the cylinder there’s another thin cylinder that can rotate (rotator), so the tool as a whole looks like a radar device. The rotator and handle are connected by a cylindrical constraint. There is a small vertical gap between the two but its not the problem.

The problem is, the player can rotate around to look freely like in any game. And when the player does that, the tool does not behave properly because the rotator detaches from the handle and then goes back to where it should be. This detachment is the issue I want to solve. Here’s a video of what it looks like (there’s a glowy orb on the handle to show where the rotator cylinder should stay.

Here’s what the tool is made of, settings for cylindrical constraint, attachment positions. I also included the place file.


radarTool.rbxl (72.1 KB)

What I tried so far:
I looked up some forum posts and saw some comments that say that the physics solver can be slow sometimes and that for constraints like the CylindricalConstraint that I’m using can be glitchy sometimes. So I tried adjusting the position with a script but it does nothing, its a simple renderstepped function that always attempts to place the rotator back on top of the handle. Not only does it not work, it pushes the player.

local tool = script.Parent
local rotator = tool.rotator
local handle = tool.Handle
local weld = tool.WeldConstraint

local rs = game:GetService("RunService")


tool.Equipped:Connect(function()
	weld.Enabled = false
	rs.RenderStepped:Connect(function()
		if rotator.Position ~= handle.Position then
			print("disconnected")
			rotator.Position = handle.Position
		end
	end)
end)

tool.Unequipped:Connect(function()
	weld.Enabled = true
end)

I also tried creating a mesh of a hollow cylinder with preciseconvexdecompositions collision fidelity and putting it around the rotator to push it back to the intended position, both mesh and rotator to cancollide = true, welded the mesh to the handle. The rotator clips through the mesh when the player turns, making me think the physics engine simply cannot keep up with a rotating tool in the player’s hand, because both collision detection and cylindrical constraints were not working as I want.

Any ideas? Thanks in advance

That how roblox physics work…
You can try applying same angular velocity to a tool that character has as a “hacky” solution

do you mean I have to apply angular velocity to the whole tool? I was hoping to just rotate one part. The tool is supposed to be a staff with some design on it so it would look weird if the whole thing was moving.
If that’s how roblox physics works does that mean there’s nothing at all that can be done about this?

No
This part on top that is connected to a hingeconstraint

I finally figured it out. The answer was a Weld, not any of the mechanical constraints. A regular Weld (not a WeldConstraint) has the properties C0 and C1 that you can manipulate with a script. Using a Weld lets you a) keep the rotator part on the handle even if you move and rotate your player as much as you want and b) allows you to actually rotate the rotator. The problem is that you have to define the movement yourself with a script, which means if you wanted to rotate the part with AlignOrientation or something it wont work. Here’s how it looks like.


You can see that the part sits neatly on the handle. Here’s what the script for manipulating the Weld looks like.

local tool = script.Parent
local rotator = tool.rotator
local handle = tool.Handle
local weld = tool.rotatorHandleWeld

local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")

local spin = {CFrame = CFrame.Angles(0,0,math.rad(360))}
local rotation = TweenInfo.new(
	0.5, -- Time
	Enum.EasingStyle.Linear, 
	Enum.EasingDirection.Out, 
	-1, 
	false, 
	0 
)
local rotateTween = ts:Create(weld, rotation, {C1 = weld.C1 * CFrame.Angles(0,0,math.rad(180))})

tool.Equipped:Connect(function()
	rotateTween:Play()
end)

tool.Unequipped:Connect(function()
	rotateTween:Pause()
end)

I used a Tween to show the movement but it can be anything you want. You use a CFrame to move the C1 property of a Weld so Cframe.LookAt() and other constructors will work.

Also I said I used a Weld, not a WeldConstraint but you can still manipulate CFrames of Parts 0 or 1 with a WeldConstraint. I haven’t tried since Im happy with using a Weld.

Some posts that helped me figure this out:

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