Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Humanoid Figure CFrame not replicating to all other clients?

Okay so, I'm replicating the CFrame of another humanoid object controlled by the character with calling a remote event and passing the parts for arguments. The server then fires the client event to all the clients and the client sets the cframe of the limbs, but this doesn't work. Help?

Localscript fires this every 5 frames during a RunService.Renderstepped event

if (replicationTimer % 5) == 0 then
		StandEvent:FireServer("Replicate", {
			Stand.HumanoidRootPart.CFrame,
			Stand.LeftFoot.CFrame,
			Stand.LeftHand.CFrame,
			Stand.LeftLowerArm.CFrame,
			Stand.LeftUpperArm.CFrame,
			Stand.LeftUpperLeg.CFrame,
			Stand.LowerTorso.CFrame,
			Stand.RightFoot.CFrame,
			Stand.RightHand.CFrame,
			Stand.RightLowerArm.CFrame,
			Stand.RightUpperArm.CFrame,
			Stand.RightUpperLeg.CFrame,
			Stand.UpperTorso.CFrame,
			Stand.Head.CFrame
		})
	end

Server then fires to all clients

if request == "Replicate" then
    TestStandEvent:FireAllClients(player, arrayOfLimbs)
end

Client Event

StandEvent.OnClientEvent:Connect(function(Player, arrayOfLimbs)
    if Player and Player.Character:FindFirstChild("HumanoidRootPart") then
		StandTorso.CFrame = arrayOfLimbs[1]
		Stand.LeftFoot.CFrame = arrayOfLimbs[2]
		Stand.LeftHand.CFrame = arrayOfLimbs[3]
		Stand.LeftLowerArm.CFrame = arrayOfLimbs[4]
		Stand.LeftUpperArm.CFrame = arrayOfLimbs[5]
		Stand.LeftUpperLeg.CFrame = arrayOfLimbs[6]
		Stand.LowerTorso.CFrame = arrayOfLimbs[7]
		Stand.RightFoot.CFrame = arrayOfLimbs[8]
		Stand.RightHand.CFrame = arrayOfLimbs[9]
		Stand.RightLowerArm.CFrame = arrayOfLimbs[10]
		Stand.RightUpperArm.CFrame = arrayOfLimbs[11]
		Stand.RightUpperLeg.CFrame = arrayOfLimbs[12]
		Stand.UpperTorso.CFrame = arrayOfLimbs[13]
		Stand.Head.CFrame = arrayOfLimbs[14]
    end
end)

1 answer

✓ Accepted answer

You can't do this with a typical Roblox character, because they are rigged with Motor6D constraints connecting all the parts. Motor6Ds are like welds, they will prevent you from setting the MeshPart CFrames independently. If you were to remove all the Motor6D joints, and anchor all the body parts, you would see your changes replicate, though it would look very jerky at this slow replication rate. If you want to keep the character rigged, you have to be manipulating the Motor6Ds, not the MeshParts directly. Exactly what this entails depends on how the source character is being controlled. If it's using Roblox animations, you'll probably want to sync the animation on the client, because manually replicating the Motor6D.Transform is more trouble than it's worth IMHO. That said, if you feel like you want to try it, I can explain how.

4 comments

0

Okay, please tell me on how to do this.

0

Because I would like toknow.

0

You can read all the Motor6D.Transform values on Heartbeat on the server IIRC, and apply them on Stepped on the client (sending via remote event). But this scales very poorly. If you have one player controlling the limb of an NPC, you're fine. If every player is puppeting a second character... forget you ever read this, you need to use Animations or players on slow computers won't see things move.

0

And every comment in chat in your game will just be "OMG Lagggggg...."

This discussion is preserved as it was. New answers, comments, and votes are closed.