Part is getting anchored, can't figure out why

im trying to make a vr system so i can throw stuff (idc if it falls straight down atm ill deal with that later)

issue: some script is anchoring my part and im not sure how because none of them should be anchoring it

images:

scripts:
localscript for hands (only the grab part)

function GrabItem(actionName, UserInputState, InputObject, Hand)
	if InputObject.Position.Z >= 0.9 then
		local partsInHand = workspace:GetPartsInPart(Hand:WaitForChild("Hitbox"))
		local validParts = {}
		local validPartsArrayAmmount = 1
			
		for _, inst in ipairs(partsInHand) do
			if grabbableObjects[inst] then
				validParts[validPartsArrayAmmount] = inst
				validPartsArrayAmmount += 1
			end
		end
		if validParts[1] ~= nil then
			if validParts[1]:IsA("BasePart") then
				validParts[1].Anchored = false
			else
				warn("what the hell did you do how is the part you're holding not a basepart what (warn generated from: " .. validParts[1]:GetFullName() .. ")")
			end
		end
		if Hand == leftHand then itemHoldingL = validParts[1] end
		if Hand == rightHand then itemHoldingR = validParts[1] end
	elseif InputObject.Position.Z < 0.9 then
		if Hand == leftHand then
			if itemHoldingL ~= nil then
				VRModule.releaseItem(itemHoldingL, leftHand.CFrame)
				itemHoldingL = nil
			end
		end
		if Hand == rightHand then
			if itemHoldingR ~= nil then
				VRModule.releaseItem(itemHoldingR, rightHand.CFrame)
				itemHoldingR = nil
			end
		end
	end
end

module script for vr stuff

VRModule.releaseItem = function(item, releaseCFrame)
	item.CFrame = releaseCFrame
	
	local itemAncestors = DeviousService.getAncestors(item)
	local itemGroup
	for _, v in itemAncestors do
		if CollectionService:HasTag(v, "FinalItemAncestor") then
			itemGroup = v
		end
	end
	if itemGroup == nil then
		itemGroup = item
		warn("unable to find item group for specified item " .. item:GetFullName() .. ", setting to passed item")
	end
	if itemGroup:IsA("BasePart") then
		warn("item group is a basepart, unanchoring")
		itemGroup.Anchored = false
	else
		print("item group returned correct class type of " .. itemGroup.ClassName)
	end
	for _, v in itemGroup:GetDescendants() do
		if v:IsA("BasePart") then
			v.Anchored = false
			print("unanchoring " .. v:GetFullName())
		else
			print("v was not basepart " .. v:GetFullName())
		end
	end
	item.Anchored = false
	print("release item function")
end

for full (slightly dated) posts, see my original (bad) post Parts not falling when they are not anchored - #2 by RussiaDogeWithCat

I’m not too familiar with vr stuff, however is it perhaps because the server making it “anchored” automatically because the anchor changes are on self client?

perhaps give client network ownership of the object or let the server know the object has been picked up and unanchor the object

or unanchor the object from the beginning i.e. set it anchored = false in studio before playing

you could verify the above if you do some local changes and check the server view and match the positions of the objects

im not sure what you mean by the first ttwo things (im not super good at scripting but i wouldn’t call myself horrible) but i do know that i have tried to unanchor it in studio and it does work then
but that would mean its not getting anchored or unanchored ever so i feel like i should make it not have to be unanchored in studio also because it’d be annoying to have to have every item i can pick up unanchored

Are you unachoring client-side? This looks like the behavior of moving an object client-side when it’s still anchored server-side.

not unless using module scripts from the client doesn’t update the server

(first time using module scripts idk what im doing, i thought module scripts would run on the server but be executed from the client and not use a remote because remotes are kinda bad imo)

ModuleScripts are essentially like variables, so they will be of the side that they are accessed on. If a LocalScript access the module, it will be executed client-side.

im led to believe that its because the server doesn’t recognize that it is not anchored and thus theres no physics being replicated

I would just have an remote event or equivalent to let the server know that this object need to be unanchored so that it won’t be frozen in all clients view.

you also have to consider replicating to all clients, the current cframe of the object, theoretically if you were to test with 2 players, do the positions of a players held object replicate to the other player?

ah
is there any way to make it run on the server without a remote event because i don’t know i wanna learn how to make it not use a remote because remotes annoy me for whatever reason

There is no way to do that without using remotes (except for a few things that are automatically replicated, but that is irrelevant in this situation). Remotes are pretty simple. Just read the guide for how to use a RemoteEvent. I would highly recommend against RemoteFunctions as they are extremely limiting and are almost never the right option.

Although another option could just be to have all intractable objects be unanchored already, but you’ll need to use remotes anyway to tell the server about the player’s/client’s input, like picking up an object or letting go. The objects should be parented inside the player character, which must be done server-side, so that the position is controlled and updated by the client for the smoothest experience. There is more that can go into a system like that, but I’ll just leave it there for now.

EDIT: the script for grabbing is in the hands local script, i forgot to put it in this post

EDIT 2: turns out the problem was that i was using a local variable for the thing im throwing and it was getting reset every frame (i think) and changing the variable to a global variable fixed it