VR Constraints & Parts not replicating to the client

I am trying to make a VR function where you can hold the barrel for more accuracy, but while doing this is works server side, but the gun just freezes client side. It’s not firing the release function or anything,

It sort of freezes in mid air, even though its not anchored on client side.
It is also not trying to grab both things at the same time, which was what I thought at first.

Here is my code, I can’t seem to find the problem, if anything else is needed please tell me.

script.Grab.OnServerInvoke = function(client, part, arm)
	if arm == "right" then
		local body = script.Parent.BodyObject.Value
		
		if part:FindFirstChild("HandAttachment") then
			local attach = part:FindFirstChild("HandAttachment")--[[this is only if there is only one part getting held (the handle)]]
			part.Anchored = false
			body["Right Arm"].RigidConstraint.Attachment0 = attach
			body["Right Arm"].RigidConstraint.Attachment1 = body["Right Arm"].Attachment
			part.Parent = body
			body["Right Arm"].Holding.Value = part
		elseif part:FindFirstChild("SecondaryA") --[[this when the player is grabbing the second thing (or the barrel) to gain more control]] then
			part.Anchored = false
			local attach = part:FindFirstChild("SecondaryA")
			body["Left Arm"].HingeConstraint.Attachment0 = body["Left Arm"].RigidConstraint.Attachment1 --setting the new hinge constraint to the old rigid constraint
			body["Left Arm"].HingeConstraint.Attachment1 = body["Left Arm"].RigidConstraint.Attachment0 -- so the handle can move
			body["Left Arm"].RigidConstraint.Attachment0 = nil -- essentially destroying the rigid constraint
			body["Left Arm"].RigidConstraint.Attachment1 = nil-- essentially destroying the rigid constraint
			body["Right Arm"].BallSocketConstraint.Attachment0 = body["Right Arm"].Attachment -- setting the attachment for the barrel to the alternate arm
			body["Right Arm"].BallSocketConstraint.Attachment1 = attach -- setting the attachment for the barrel to the alternate arm
			body["Right Arm"].Holding.Value = part
			part.Parent = body
		end
	else if arm == "left" then
			local body = script.Parent.BodyObject.Value
			if part:FindFirstChild("HandAttachment") --[[this is only if there is only one part getting held]] then
				local attach = part:FindFirstChild("HandAttachment")
				part.Anchored = false
				body["Left Arm"].RigidConstraint.Attachment0 = attach
				body["Left Arm"].RigidConstraint.Attachment1 = body["Left Arm"].Attachment
				part.Parent = body
				body["Left Arm"].Holding.Value = part
			elseif part:FindFirstChild("SecondaryA") --[[this when the player is grabbing the second thing (or the barrel) to gain more control]] then
				part.Anchored = false
				local attach = part:FindFirstChild("SecondaryA")
				body["Right Arm"].HingeConstraint.Attachment0 = body["Right Arm"].RigidConstraint.Attachment1 --setting the new hinge constraint to the old rigid constraint 
				body["Right Arm"].HingeConstraint.Attachment1 = body["Right Arm"].RigidConstraint.Attachment0 -- so the handle can move
				body["Right Arm"].RigidConstraint.Attachment0 = nil -- essentially destroying the rigid constraint
				body["Right Arm"].RigidConstraint.Attachment1 = nil -- essentially destroying the rigid constraint
				body["Left Arm"].BallSocketConstraint.Attachment0 = body["Left Arm"].Attachment -- setting the attachment for the barrel to the alternate arm
				body["Left Arm"].BallSocketConstraint.Attachment1 = attach -- setting the attachment for the barrel to the alternate arm
				body["Left Arm"].Holding.Value = part
				part.Parent = body
			end
			
		end
	end
end

1 Like

I have tried to replicate the same sort of issue in Roblox Studio, and I was not able to get the same behavior to occur on Client Side, is there isn’t anything on client side that might be anchoring one of the parts once one of the RigidConstraints attachment properties are set to nil?

That’s the only issues I can think of that would cause this issue, as everything shown running serverside, works as intended, and the code from what I can tell works.

If you could provide some snippets of Client Side code that may be related to the code, that’d be helpful.