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.
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)
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)
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.