Body Position & Gyro aren't replicating? VR

i found a similar problem but this had no answer. Changes to body position not replicating to server

i think the issue is setnetworkowner - look at my modules being run on the server.


CharacterModule

local module = {}

-- //Services

-- //Modules
local WeldModule = require(script:FindFirstChild("WeldModule"))

function module:create(player, character)
	
	-- //Humanoid
	local Humanoid = character:FindFirstChild("Humanoid")
	
	Humanoid.RequiresNeck = false
	
	-- //for loop
	for _, part in ipairs(character:GetChildren()) do
		if part:IsA("BasePart") then
			
			-- //SetNetworkOwner
			part:SetNetworkOwner(player)
			
		end
	end
	
	-- //for loop
	for a, joint in ipairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			joint:Destroy()
		end
	end
	
	WeldModule:weld(player, character)
	
end

return module

PositionModule

local module = {}

-- //Services
local RunService = game:GetService("RunService")

-- //Tables
local ObjTable = {
	Velocity = script:FindFirstChild("BodyPosition"),
	Gyro = script:FindFirstChild("BodyGyro")
}

function module:physics(player, character)

	-- //for loop
	for b, part in ipairs(character:GetChildren()) do
		if part:IsA("BasePart") and string.match(part.Name, "Arm") or string.match(part.Name, "Head") then
				
			-- //for loop
			for index, obj in pairs(ObjTable) do
				
				-- //Clone
				local Clone = obj:Clone()
				
				-- //
				
				if not part:FindFirstChild(obj.Name) then
					Clone.Parent = part
				end
				
				-- //
			end
			-- //
		end
	end
	
end


return module

Client Script

-- //Services
local VRService = game:GetService("VRService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")

-- //Folders
local RemoteEvents = ReplicatedStorage:FindFirstChild("RemoteEvents")

-- //Remotes
local VREnabled = RemoteEvents:FindFirstChild("VREnabled")

-- //Character 
local character = script.Parent

-- //Player
local player = Players:GetPlayerFromCharacter(character)

-- //BaseParts
local Head = character:FindFirstChild("Head")
local RightArm = character:FindFirstChild("Right Arm")
local LeftArm = character:FindFirstChild("Left Arm")



-- //
if VRService.VREnabled then
	player.CameraMode = Enum.CameraMode.LockFirstPerson
	VREnabled:FireServer()
end


-- //Body
local BodyPosHead = Head:FindFirstChild("BodyPosition")
local BodyGyroHead = Head:FindFirstChild("BodyGyro")
local BodyPosRightArm = RightArm:FindFirstChild("BodyPosition")
local BodyGyroRightArm = RightArm:FindFirstChild("BodyGyro")
local BodyPosLeftArm = LeftArm:FindFirstChild("BodyPosition")
local BodyGyroLeftArm = LeftArm:FindFirstChild("BodyGyro")

if BodyPosHead or BodyGyroHead or BodyPosRightArm or BodyGyroRightArm or BodyPosLeftArm or BodyGyroLeftArm then
	print("Body Loaded!")
end


-- //
if VRService.VREnabled then
	RunService.RenderStepped:Connect(function(deltaTime: number) 
		
		-- //VR
		local HeadVR = VRService:GetUserCFrame(Enum.UserCFrame.Head)
		local RightVR = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
		local LeftVR = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)

		Head.CFrame = Camera.CFrame * HeadVR * BodyGyroHead.CFrame + BodyPosHead.Position
		RightArm.CFrame = Camera.CFrame * RightVR:ToWorldSpace(CFrame.Angles(math.rad(90), 0, 0)) *  BodyGyroRightArm.CFrame + BodyPosRightArm.Position
		LeftArm.CFrame = Camera.CFrame * LeftVR:ToWorldSpace(CFrame.Angles(math.rad(90), 0, 0)) *  BodyGyroLeftArm.CFrame + BodyPosLeftArm.Position
		
		-- //for loop
		for _, child in ipairs(character:GetChildren()) do
			if child:IsA("BasePart") and child.Name ~= "Head" then
				child.LocalTransparencyModifier = 0.75
			end
		end
		
	end)
end

the body instances are getting registered but idk why its not replicating. i took off setnetworkown on the server to test if it would work and it still doesnt.

another solution - which was found but not fully answered.

TL;DR: Make sure that every part of the body has network ownership set to the player.

It’s possible that when you’re removing welds it resets the assemblies’s network ownership to the server. Maybe set the ownership after making modifications.

If the client has ownership of all the parts, the parts are unanchored on both the client and the server, the physics from the client should always replicate.

Edit:

Also, this statement should use ands, so that it prints only if everything is loaded, instead of only one thing.

Edit:

Nice, glad I could help!

imma test this.

(adding more characters for a reply)

Oh, I think I see the problem. Are you controlling the body parts with physics (ie the body movers) or are you controlling them by setting the CFrame directly?

I believe instead of the lines above, you should be setting the control properties of the respective body movers. Setting CFrames isn’t physics based, and network ownership is for replicating physics updates.

E.g:
Instead of

Head.CFrame = Camera.CFrame * HeadVR * BodyGyroHead.CFrame + BodyPosHead.Position

do

local headCFrame = Camera.CFrame * HeadVR * BodyGyroHead.CFrame + BodyPosHead.Position
BodyPosHead.Position = headCFrame.Position
BodyGyroHead.CFrame = headCFrame

This will cause the physics-based body movers to do the movements, which should replicate properly if the ownership is set to the client.

i tried this on each arm and head now the server is replicating :joy:

the client was handling it but not replicating now its showing what the server is doing

its staying in its given bodyposition = 0 on the vector and the cframe isnt working

-- //
if VRService.VREnabled then
	RunService.RenderStepped:Connect(function(deltaTime: number) 
		
		-- //VR
		local HeadVR = VRService:GetUserCFrame(Enum.UserCFrame.Head)
		local RightVR = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
		local LeftVR = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)

		local headCFrame = Camera.CFrame * HeadVR * BodyGyroHead.CFrame + BodyPosHead.Position
		BodyPosHead.Position = headCFrame.Position
		BodyGyroHead.CFrame = headCFrame
		
		local rightCFrame = Camera.CFrame * RightVR * BodyGyroRightArm.CFrame + BodyPosRightArm.Position
		BodyPosRightArm.Position = rightCFrame.Position
		BodyGyroRightArm.CFrame = rightCFrame
		
		-- //for loop
		for _, child in ipairs(character:GetChildren()) do
			if child:IsA("BasePart") and child.Name ~= "Head" then
				child.LocalTransparencyModifier = 0.75
			end
		end
		
	end)
end

I would check:

  • That the network ownership of all the parts is set to the client.
  • That the client code is running on the client.
  • That the RunService connection is being made

You can check these by:

  • Playtesting
  • Verifying that the values of the body movers are changing on the client
  • If they aren’t, it means one of 2 or 3 isn’t true
  • If they aren’t changing, try setting them manually. If this moves the part, then one is true.
  • If they aren’t changing on the client and manually changing them doesn’t move the parts, then none of the 3 are true.

you solved it - it was the joints being broken after the parts were being setnetworkowner, so i swapped the for loops around.

UPDATED CHARACTERMODULE

local module = {}

-- //Services

-- //Modules
local WeldModule = require(script:FindFirstChild("WeldModule"))

function module:create(player, character)
	
	-- //Humanoid
	local Humanoid = character:FindFirstChild("Humanoid")
	
	Humanoid.RequiresNeck = false
	Humanoid.HipHeight = 2
	
	-- //for loop
	for a, joint in ipairs(character:GetDescendants()) do
		if joint:IsA("Motor6D") then
			joint:Destroy()
		end
	end
	
	
	-- //for loop
	for _, part in ipairs(character:GetChildren()) do
		if part:IsA("BasePart") then

			-- //SetNetworkOwner
			part:SetNetworkOwner(player)

		end
	end
	
	WeldModule:weld(player, character)
	
end

return module

THANK U!!

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