CFrame value is randomly changing between client and server

So, I am making a building system that uses previews on the clientside and then transfers the data about the position and whatnot once the building is “placed” to place it on the serverside.

For some reason, the CFrame position is working fine, but the CFrame rotation is different.

On the clientside, I’ll get something like this when I print out the CFrame:
8, 47.4999771, -236, -4.37113883e-08, 0, 1, 0, 1, 0, -1, 0, -4.37113883e-08
And on the serverside, passing through part.CFrame it reads like this:
8, 47.4999771, -236, 0, 0, 1, 0, 1, -0, -1, 0, 0

Not really sure what’s happening here. Any thoughts? It’s resulting in a really weird issue where the position is correct, but not the orientation of the part/model.

2 Likes

Try sending the position and rotation of the CFrame in seperate variables, then collect them on the server side. Here’s an example if it helps:

local PartCFrame = game.Workspace.Part.CFrame
local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent

local Position = PartCFrame.Position
local Rotation = PartCFrame.Rotation

RemoteEvent:FireServer(Position, Rotation)

Still the same issue, for some reason. Though now, the part is rotate by 90 degrees from what its supposed to be…

Is it consistently 90 degrees off from the actual part rotation?

Seems like it now after separating the position and rotation, yes.

As an example, with my code (it’s literally just the same as you suggested:

External Media

CLIENT:

Events.PlaceBuildable:FireServer(buildable.Name, buildingPreview.PrimaryPart.CFrame.Rotation, buildingPreview.PrimaryPart.CFrame.Position)

SERVER:

Events.PlaceBuildable.OnServerEvent:Connect(function(Player, buildableName, rotation, position)
	if not Player or not buildableName or not rotation or not position then warn("Didn't have proper info for some reason to place building.") return end
		
	
		
	local buildable = game.ReplicatedStorage.ObjectData.Buildables:FindFirstChild(buildableName, true):Clone()
	buildable.Parent = game.Workspace.Buildings:FindFirstChild(Player.Name)
	buildable:PivotTo(CFrame.new(position.X, position.Y, position.Z) * rotation)
-- Ignore the fact I broke the position into three elements, I was just testing something out.
	
end)

Quick question, which axis is it 90 degrees off of? Like x, y, or z?

Y axis, it looks like.

Is this one of those fun cases where it’s YXZ instead of XYZ? That would make sense. I always forget how this works. Though that doesn’t make sense in the cases where X and Z are both 0, because it’s not causing a rotation issue on another axis.

I have resolved this by rotating the pivot by 90 degrees on the Y axis, at least for now.